lyhzzz 1 year ago
parent
commit
c7ccc11bd3
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/main/java/com/fdkankan/fusion/service/impl/UploadService.java

+ 2 - 2
src/main/java/com/fdkankan/fusion/service/impl/UploadService.java

@@ -88,7 +88,7 @@ public class UploadService {
             if(newName){
                 fileName = UUID.randomUUID().toString().replace("-","") ;
             }else {
-                fileName= URLEncoder.encode(fileName.substring(0,fileName.lastIndexOf(".")),"utf-8");
+                fileName= fileName.substring(0,fileName.lastIndexOf("."));
             }
             if(fileName.length() >50){
                 fileName =  fileName.substring(0,50);
@@ -100,7 +100,7 @@ public class UploadService {
             if(!uploadToOssUtil.existKey(filePathAdd + fileName + suffixName)){
                 throw new BusinessException(ResultCode.UPLOAD_ERROR.code,ResultCode.UPLOAD_ERROR.msg);
             }
-            return queryPath +filePathAdd+ fileName + suffixName;
+            return queryPath +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);