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

解决文件输入流为可能为空的问题

maochd пре 3 година
родитељ
комит
3786f3671d

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

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