|
@@ -5,9 +5,12 @@ import com.fdkankan.fusion.common.ResultCode;
|
|
|
import com.fdkankan.fusion.common.util.ShellUtil;
|
|
|
import com.fdkankan.fusion.common.util.UploadToOssUtil;
|
|
|
import com.fdkankan.fusion.common.util.VideoUtil;
|
|
|
+import com.fdkankan.fusion.config.FusionConfig;
|
|
|
import com.fdkankan.fusion.exception.BusinessException;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -25,10 +28,10 @@ import java.util.UUID;
|
|
|
public class UploadService {
|
|
|
|
|
|
@Resource
|
|
|
- private UploadToOssUtil uploadToOssUtil;
|
|
|
+ private FYunFileServiceInterface fYunFileServiceInterface;
|
|
|
+ @Autowired
|
|
|
+ FusionConfig fusionConfig;
|
|
|
|
|
|
- @Value("${upload.query-path}")
|
|
|
- private String queryPath;
|
|
|
@Value("${spring.profiles.active}")
|
|
|
private String environment;
|
|
|
|
|
@@ -96,11 +99,11 @@ public class UploadService {
|
|
|
localFile = File.createTempFile(fileName + suffixName,suffixName);
|
|
|
file.transferTo(localFile);
|
|
|
String path = localFile.getPath();
|
|
|
- uploadToOssUtil.uploadOss(path,filePathAdd+ fileName + suffixName);
|
|
|
- if(!uploadToOssUtil.existKey(filePathAdd + fileName + suffixName)){
|
|
|
+ fYunFileServiceInterface.uploadFile(path,filePathAdd+ fileName + suffixName);
|
|
|
+ if(!fYunFileServiceInterface.fileExist(filePathAdd + fileName + suffixName)){
|
|
|
throw new BusinessException(ResultCode.UPLOAD_ERROR.code,ResultCode.UPLOAD_ERROR.msg);
|
|
|
}
|
|
|
- return queryPath +filePathAdd+ URLEncoder.encode(fileName,"utf-8") + suffixName;
|
|
|
+ return fusionConfig.getOssUrlPrefix() +filePathAdd+ URLEncoder.encode(fileName,"utf-8") + suffixName;
|
|
|
}catch (Exception e){
|
|
|
log.info("upload-error:{}",e);
|
|
|
throw new BusinessException(ResultCode.UPLOAD_ERROR.code,ResultCode.UPLOAD_ERROR.msg);
|
|
@@ -114,8 +117,8 @@ public class UploadService {
|
|
|
|
|
|
public void deleteOssUrl(String path) {
|
|
|
try {
|
|
|
- String replace = path.replace(queryPath, "");
|
|
|
- uploadToOssUtil.delete(replace);
|
|
|
+ String replace = path.replace(fusionConfig.getOssUrlPrefix(), "");
|
|
|
+ fYunFileServiceInterface.deleteFile(replace);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|