Преглед изворни кода

修复使用FastDFS上传头像失败提示文件名没有后缀问题

RuoYi пре 3 година
родитељ
комит
8fdb3c4d14

+ 2 - 2
ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/FastDfsSysFileServiceImpl.java

@@ -1,12 +1,12 @@
1
 package com.ruoyi.file.service;
1
 package com.ruoyi.file.service;
2
 
2
 
3
-import org.apache.commons.io.FilenameUtils;
4
 import org.springframework.beans.factory.annotation.Autowired;
3
 import org.springframework.beans.factory.annotation.Autowired;
5
 import org.springframework.beans.factory.annotation.Value;
4
 import org.springframework.beans.factory.annotation.Value;
6
 import org.springframework.stereotype.Service;
5
 import org.springframework.stereotype.Service;
7
 import org.springframework.web.multipart.MultipartFile;
6
 import org.springframework.web.multipart.MultipartFile;
8
 import com.github.tobato.fastdfs.domain.fdfs.StorePath;
7
 import com.github.tobato.fastdfs.domain.fdfs.StorePath;
9
 import com.github.tobato.fastdfs.service.FastFileStorageClient;
8
 import com.github.tobato.fastdfs.service.FastFileStorageClient;
9
+import com.ruoyi.common.core.utils.file.FileTypeUtils;
10
 
10
 
11
 /**
11
 /**
12
  * FastDFS 文件存储
12
  * FastDFS 文件存储
@@ -36,7 +36,7 @@ public class FastDfsSysFileServiceImpl implements ISysFileService
36
     public String uploadFile(MultipartFile file) throws Exception
36
     public String uploadFile(MultipartFile file) throws Exception
37
     {
37
     {
38
         StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
38
         StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
39
-                FilenameUtils.getExtension(file.getOriginalFilename()), null);
39
+                FileTypeUtils.getExtension(file), null);
40
         return domain + "/" + storePath.getFullPath();
40
         return domain + "/" + storePath.getFullPath();
41
     }
41
     }
42
 }
42
 }