Browse Source

fileStore私有域客户端文件访问时长

wangliang 2 years ago
parent
commit
f759ada355

+ 2 - 26
teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/FileStoreUtil.java

@@ -215,7 +215,8 @@ public class FileStoreUtil {
             return server + "/" + objectPath;
         } else if ("private".equals(type)) {
             Boolean oss = dictionaryConfig.sysDomain().isOss();
-            if (Objects.nonNull(oss) && oss) {
+            if (Objects.nonNull(oss) && oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith("oss:") &&
+                    (dictionaryConfig.fssPrivateDomain().getServer().startsWith("http:") || dictionaryConfig.fssPrivateDomain().getServer().startsWith("https:"))) {
                 FileStore fileStore = fileService.getFileStore(type);
                 return fileStore.getPresignedUrl(objectPath, Duration.ofMinutes(5L));
             } else {
@@ -226,31 +227,6 @@ public class FileStoreUtil {
         }
     }
 
-    /**
-     * 获取文件访问url
-     *
-     * @param objectPath 文件路径
-     * @param type       文件上传的类型
-     * @return
-     */
-    public String getPrivateUrlByClient(String objectPath, String type) {
-        String server = null;
-        if ("public".equals(type)) {
-            server = dictionaryConfig.fssPublicDomain().getServer();
-            return server + SystemConstant.ORG_SPLIT + objectPath;
-        } else if ("private".equals(type)) {
-            Boolean oss = dictionaryConfig.sysDomain().isOss();
-            if (Objects.nonNull(oss) && oss) {
-                FileStore fileStore = fileService.getFileStore(type);
-                return fileStore.getPresignedUrl(objectPath, Duration.ofMinutes(120L));
-            } else {
-                return dictionaryConfig.fssPrivateDomain().getServer() + SystemConstant.ORG_SPLIT + objectPath;
-            }
-        } else {
-            throw ExceptionResultEnum.ERROR.exception("文件存储store类型不存在");
-        }
-    }
-
     /**
      * 根据数据库文件路径判断文件上传类型
      *