|
@@ -1,6 +1,7 @@
|
|
package com.qmth.teachcloud.common.util;
|
|
package com.qmth.teachcloud.common.util;
|
|
|
|
|
|
import com.qmth.boot.core.fss.service.FileService;
|
|
import com.qmth.boot.core.fss.service.FileService;
|
|
|
|
+import com.qmth.boot.core.fss.store.FileStore;
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.UploadFileEnum;
|
|
import com.qmth.teachcloud.common.enums.UploadFileEnum;
|
|
@@ -13,6 +14,8 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
|
|
+import java.time.Duration;
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: 文件存储工具类
|
|
* @Description: 文件存储工具类
|
|
@@ -118,12 +121,18 @@ public class FileStoreUtil {
|
|
String server;
|
|
String server;
|
|
if ("public".equals(type)) {
|
|
if ("public".equals(type)) {
|
|
server = dictionaryConfig.fssPublicDomain().getServer();
|
|
server = dictionaryConfig.fssPublicDomain().getServer();
|
|
|
|
+ return server + "/" + objectPath;
|
|
} else if ("private".equals(type)) {
|
|
} else if ("private".equals(type)) {
|
|
- server = dictionaryConfig.fssPrivateDomain().getServer();
|
|
|
|
|
|
+ Boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
|
+ if (Objects.nonNull(oss) && oss) {
|
|
|
|
+ FileStore fileStore = fileService.getFileStore(type);
|
|
|
|
+ return fileStore.getTemporaryUrl(objectPath, Duration.ofMinutes(5L));
|
|
|
|
+ } else {
|
|
|
|
+ return dictionaryConfig.fssPrivateDomain().getServer() + "/" + objectPath;
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
throw ExceptionResultEnum.ERROR.exception("文件存储store类型不存在");
|
|
throw ExceptionResultEnum.ERROR.exception("文件存储store类型不存在");
|
|
}
|
|
}
|
|
- return server + "/" + objectPath;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|