|
@@ -1,12 +1,10 @@
|
|
|
package com.qmth.teachcloud.common.util;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.qmth.boot.core.fss.service.FileService;
|
|
|
+import com.qmth.boot.core.fss.service.FileStoreService;
|
|
|
import com.qmth.boot.core.fss.store.FileStore;
|
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
|
-import com.qmth.teachcloud.common.contant.SpringContextHolder;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
-import com.qmth.teachcloud.common.domain.FssDomain;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.teachcloud.common.enums.LocalCatalogEnum;
|
|
|
import com.qmth.teachcloud.common.enums.UploadFileEnum;
|
|
@@ -36,7 +34,7 @@ public class FileStoreUtil {
|
|
|
private final static Logger log = LoggerFactory.getLogger(FileStoreUtil.class);
|
|
|
|
|
|
@Resource
|
|
|
- private FileService fileService;
|
|
|
+ private FileStoreService fileStoreService;
|
|
|
|
|
|
@Resource
|
|
|
private DictionaryConfig dictionaryConfig;
|
|
@@ -75,7 +73,7 @@ public class FileStoreUtil {
|
|
|
break;
|
|
|
}
|
|
|
dirName = dirName.replaceAll(configPath, "");
|
|
|
- fileService.getFileStore(catalogType.getType()).write(dirName, inputStream, md5);
|
|
|
+ fileStoreService.getFileStore(catalogType.getType()).write(dirName, inputStream, md5);
|
|
|
log.info("dirName:{}", dirName);
|
|
|
}
|
|
|
|
|
@@ -88,7 +86,7 @@ public class FileStoreUtil {
|
|
|
*/
|
|
|
public void ossUpload(String dirName, InputStream inputStream, String md5, String type) throws Exception {
|
|
|
log.info("ossUpload is come in");
|
|
|
- fileService.getFileStore(type).write(dirName, inputStream, md5);
|
|
|
+ fileStoreService.getFileStore(type).write(dirName, inputStream, md5);
|
|
|
log.info("dirName:{}", dirName);
|
|
|
}
|
|
|
|
|
@@ -113,7 +111,7 @@ public class FileStoreUtil {
|
|
|
// break;
|
|
|
// }
|
|
|
// dirName = dirName.replaceAll(configPath, "");
|
|
|
-// fileService.getFileStore(catalogType.getType()).write(dirName, inputStream, md5);
|
|
|
+// fileStoreService.getFileStore(catalogType.getType()).write(dirName, inputStream, md5);
|
|
|
// log.info("dirName:{}", dirName);
|
|
|
// }
|
|
|
|
|
@@ -139,7 +137,7 @@ public class FileStoreUtil {
|
|
|
*/
|
|
|
public void ossUpload(String dirName, File file, String md5, String type) throws Exception {
|
|
|
log.info("ossUpload is come in");
|
|
|
- fileService.getFileStore(type).write(dirName, new FileInputStream(file), md5);
|
|
|
+ fileStoreService.getFileStore(type).write(dirName, new FileInputStream(file), md5);
|
|
|
log.info("dirName:{}", dirName);
|
|
|
}
|
|
|
|
|
@@ -152,7 +150,7 @@ public class FileStoreUtil {
|
|
|
*/
|
|
|
public void ossUpload(String dirName, String content, String type) throws Exception {
|
|
|
log.info("ossUpload is come in");
|
|
|
- fileService.getFileStore(type).write(dirName, new ByteArrayInputStream(content.getBytes()), DigestUtils.md5Hex(new ByteArrayInputStream(content.getBytes())));
|
|
|
+ fileStoreService.getFileStore(type).write(dirName, new ByteArrayInputStream(content.getBytes()), DigestUtils.md5Hex(new ByteArrayInputStream(content.getBytes())));
|
|
|
log.info("dirName:{}", dirName);
|
|
|
}
|
|
|
|
|
@@ -166,7 +164,7 @@ public class FileStoreUtil {
|
|
|
*/
|
|
|
public File ossDownload(String dirName, String localPath, String type) throws Exception {
|
|
|
log.info("ossDownload is come in");
|
|
|
- return this.saveLocal(fileService.getFileStore(type).read(dirName), localPath);
|
|
|
+ return this.saveLocal(fileStoreService.getFileStore(type).read(dirName), localPath);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -179,7 +177,7 @@ public class FileStoreUtil {
|
|
|
*/
|
|
|
public File ossDownload(String dirName, File localFile, String type) throws Exception {
|
|
|
log.info("ossDownload is come in");
|
|
|
- InputStream inputStream = fileService.getFileStore(type).read(dirName);
|
|
|
+ InputStream inputStream = fileStoreService.getFileStore(type).read(dirName);
|
|
|
FileUtils.copyInputStreamToFile(inputStream, localFile);
|
|
|
return localFile;
|
|
|
}
|
|
@@ -193,7 +191,7 @@ public class FileStoreUtil {
|
|
|
*/
|
|
|
public byte[] ossDownload(String objectName, String type) throws Exception {
|
|
|
log.info("oss Download is come in");
|
|
|
- return IOUtils.toByteArray(fileService.getFileStore(type).read(objectName));
|
|
|
+ return IOUtils.toByteArray(fileStoreService.getFileStore(type).read(objectName));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -205,7 +203,7 @@ public class FileStoreUtil {
|
|
|
*/
|
|
|
public InputStream ossDownloadIs(String objectName, String type) throws Exception {
|
|
|
log.info("oss Download is come in");
|
|
|
- return fileService.getFileStore(type).read(objectName);
|
|
|
+ return fileStoreService.getFileStore(type).read(objectName);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -223,8 +221,8 @@ public class FileStoreUtil {
|
|
|
} 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(5L));
|
|
|
+ FileStore fileStore = fileStoreService.getFileStore(type);
|
|
|
+ return fileStore.getServerUrl(objectPath, Duration.ofMinutes(5L));
|
|
|
} else {
|
|
|
if (objectPath.startsWith(SystemConstant.ORG_SPLIT)) {
|
|
|
return dictionaryConfig.fssPrivateDomain().getServer() + objectPath;
|
|
@@ -252,7 +250,7 @@ public class FileStoreUtil {
|
|
|
} else if ("private".equals(type)) {
|
|
|
Boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
if (Objects.nonNull(oss) && oss) {
|
|
|
- FileStore fileStore = fileService.getFileStore(type);
|
|
|
+ FileStore fileStore = fileStoreService.getFileStore(type);
|
|
|
return fileStore.getServer() + SystemConstant.ORG_SPLIT;
|
|
|
} else {
|
|
|
if (objectPath.startsWith(SystemConstant.ORG_SPLIT)) {
|
|
@@ -281,11 +279,11 @@ public class FileStoreUtil {
|
|
|
} else if ("private".equals(type)) {
|
|
|
Boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
if (Objects.nonNull(oss) && oss) {
|
|
|
- FileStore fileStore = fileService.getFileStore(type);
|
|
|
+ FileStore fileStore = fileStoreService.getFileStore(type);
|
|
|
if (isExpire) {
|
|
|
- return fileStore.getPresignedUrl(objectPath, Duration.ofMinutes(5L));
|
|
|
+ return fileStore.getServerUrl(objectPath, Duration.ofMinutes(5L));
|
|
|
} else {
|
|
|
- return fileStore.getPresignedUrl(objectPath, Duration.ofMinutes(300L));
|
|
|
+ return fileStore.getServerUrl(objectPath, Duration.ofMinutes(300L));
|
|
|
}
|
|
|
} else {
|
|
|
return dictionaryConfig.fssPrivateDomain().getServer() + SystemConstant.ORG_SPLIT + objectPath;
|