Bläddra i källkod

修改文件上传默认路径

zhouhao 7 år sedan
förälder
incheckning
ea0b30c415

+ 7 - 7
hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-simple/src/main/java/org/hswebframework/web/service/file/simple/LocalFileService.java

@@ -28,24 +28,24 @@ public class LocalFileService implements FileService {
     /**
      * 静态文件存储目录,不能以/结尾
      */
-    private String staticFilePath = "./static";
+    private String staticFilePath = "./static/upload";
 
     /**
      * 静态文件访问地址,上传静态文件后,将返回此地址+文件相对地址,以/结尾
      */
-    private String staticLocation = "/";
+    private String staticLocation = "/upload";
 
     /**
      * 文件上传目录
      */
-    private String filePath = "./upload";
+    private String filePath = "./upload/file";
 
-    @Value("${hsweb.web.upload.static-file-path:./static}")
+    @Value("${hsweb.web.upload.static-file-path:./static/upload}")
     public void setStaticFilePath(String staticFilePath) {
         this.staticFilePath = staticFilePath;
     }
 
-    @Value("${hsweb.web.upload.static-location:/upload/static}")
+    @Value("${hsweb.web.upload.static-location:/upload}")
     public void setStaticLocation(String staticLocation) {
         this.staticLocation = staticLocation;
     }
@@ -79,7 +79,7 @@ public class LocalFileService implements FileService {
             throw new NotFoundException("file not found or disabled");
         }
         //配置中的文件上传根路径
-        String filePath =getFilePath()+"/"+ fileInfo.getLocation();
+        String filePath = getFilePath() + "/" + fileInfo.getLocation();
         File file = new File(filePath);
         if (!file.exists()) {
             throw new NotFoundException("file not found");
@@ -102,7 +102,7 @@ public class LocalFileService implements FileService {
         String filePath = DateFormatter.toString(new Date(), "yyyyMMdd");
 
         //创建目录
-        new File(getStaticFilePath()+"/"+filePath).mkdirs();
+        new File(getStaticFilePath() + "/" + filePath).mkdirs();
 
         // 存储的文件名
         String realFileName = System.nanoTime() + suffix;