Browse Source

上传文件判断

lyhzzz 3 năm trước cách đây
mục cha
commit
c3fa8a6059

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

@@ -54,10 +54,14 @@ public class UploadService {
             if(filePathSet !=null){
             if(filePathSet !=null){
                 filePathSet.add(path);
                 filePathSet.add(path);
             }
             }
-            VideoUtil.ffmpegVideo(path,path.replace(suffixName,".jpg"),"200","200");
-
+            if(file.getName().toLowerCase().endsWith(".mp4")){
+                VideoUtil.ffmpegVideo(path,path.replace(suffixName,".jpg"),"200","200");
+                uploadToOssUtil.upload(path.replace(suffixName,".jpg"),filePathAdd+ fileName + ".jpg");
+                if(!uploadToOssUtil.existKey(filePathAdd+ fileName + ".jpg")){
+                    throw new BusinessException(ResultCode.UPLOAD_ERROR.code,ResultCode.UPLOAD_ERROR.msg);
+                }
+            }
             uploadToOssUtil.upload(path,filePathAdd+ fileName + suffixName);
             uploadToOssUtil.upload(path,filePathAdd+ fileName + suffixName);
-            uploadToOssUtil.upload(path.replace(suffixName,".jpg"),filePathAdd+ fileName + ".jpg");
             if(!uploadToOssUtil.existKey(filePathAdd + fileName + suffixName)){
             if(!uploadToOssUtil.existKey(filePathAdd + fileName + suffixName)){
                 throw new BusinessException(ResultCode.UPLOAD_ERROR.code,ResultCode.UPLOAD_ERROR.msg);
                 throw new BusinessException(ResultCode.UPLOAD_ERROR.code,ResultCode.UPLOAD_ERROR.msg);
             }
             }