Browse Source

!321 解决文件输入流为可能为空的问题
Merge pull request !321 from maochd/master

若依 3 years ago
parent
commit
5fcec99e6c

+ 2 - 9
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/file/FileUtils.java

@@ -126,15 +126,8 @@ public class FileUtils
126 126
         {
127 127
             return false;
128 128
         }
129
-
130
-        // 检查允许下载的文件规则
131
-        if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource)))
132
-        {
133
-            return true;
134
-        }
135
-
136
-        // 不在允许下载的文件规则
137
-        return false;
129
+        // 判断是否在允许下载的文件规则内
130
+        return ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource));
138 131
     }
139 132
 
140 133
     /**

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

@@ -1,6 +1,8 @@
1 1
 package com.ruoyi.file.service;
2 2
 
3 3
 import java.io.InputStream;
4
+
5
+import com.alibaba.nacos.common.utils.IoUtils;
4 6
 import org.springframework.beans.factory.annotation.Autowired;
5 7
 import org.springframework.beans.factory.annotation.Value;
6 8
 import org.springframework.stereotype.Service;
@@ -39,7 +41,7 @@ public class FastDfsSysFileServiceImpl implements ISysFileService
39 41
         InputStream inputStream = file.getInputStream();
40 42
         StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(),
41 43
                 FileTypeUtils.getExtension(file), null);
42
-        inputStream.close();
44
+        IoUtils.closeQuietly(inputStream);
43 45
         return domain + "/" + storePath.getFullPath();
44 46
     }
45 47
 }