소스 검색

修复文件上传时java.nio.file.FileAlreadyExistsException

libin 3 년 전
부모
커밋
14ea071306
1개의 변경된 파일4개의 추가작업 그리고 8개의 파일을 삭제
  1. 4 8
      ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java

+ 4 - 8
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java

@@ -130,14 +130,10 @@ public class FileUploadUtils
     private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
     {
         File desc = new File(uploadDir + File.separator + fileName);
-
-        if (!desc.getParentFile().exists())
-        {
-            desc.getParentFile().mkdirs();
-        }
-        if (!desc.exists())
-        {
-            desc.createNewFile();
+        if (!desc.exists()) {
+            if (!desc.getParentFile().exists()) {
+                desc.getParentFile().mkdirs();
+            }
         }
         return desc;
     }