|
@@ -227,6 +227,36 @@ public class FileStoreUtil {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取文件访问url
|
|
|
|
+ *
|
|
|
|
+ * @param objectPath 文件路径
|
|
|
|
+ * @param type 文件上传的类型
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public String getPrivateUrlExpire(String objectPath, String type, Boolean isExpire) {
|
|
|
|
+ String server = null;
|
|
|
|
+ if ("public".equals(type)) {
|
|
|
|
+ server = dictionaryConfig.fssPublicDomain().getServer();
|
|
|
|
+ return server + "/" + objectPath;
|
|
|
|
+ } else if ("private".equals(type)) {
|
|
|
|
+ Boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
|
+ 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);
|
|
|
|
+ if(isExpire) {
|
|
|
|
+ return fileStore.getPresignedUrl(objectPath, Duration.ofMinutes(5L));
|
|
|
|
+ } else {
|
|
|
|
+ return fileStore.getPresignedUrl(objectPath, Duration.ofMinutes(300L));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return dictionaryConfig.fssPrivateDomain().getServer() + "/" + objectPath;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("文件存储store类型不存在");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据数据库文件路径判断文件上传类型
|
|
* 根据数据库文件路径判断文件上传类型
|
|
*
|
|
*
|