Ver código fonte

vector 模块 删除文件成功

wuweihao 5 anos atrás
pai
commit
b75c67b3eb

+ 22 - 9
src/main/java/com/fd/server/impl/VectorServerImpl.java

@@ -103,7 +103,8 @@ public class VectorServerImpl implements VectorServer {
 
         // 删除文件
         if (entity.getUploadPath() != null) {
-            FileUtils.delFolder(entity.getUploadPath());
+            String path = entity.getUploadPath();
+            deleteFolder(path, entity);
         }
 
         if (entity.getUnZipPath() != null) {
@@ -111,15 +112,18 @@ public class VectorServerImpl implements VectorServer {
         }
 
         if (entity.getCoordGeneralPath() != null) {
-            FileUtils.delFolder(entity.getCoordGeneralPath());
+            String path = entity.getCoordGeneralPath();
+            deleteFolder(path, entity);
         }
 
         if (entity.getCoordStrictPath() != null) {
-            FileUtils.delFolder(entity.getCoordStrictPath());
+            String path = entity.getCoordStrictPath();
+            deleteFolder(path, entity);
         }
 
         if (entity.getGeojsonPath() != null) {
-            FileUtils.delFolder(entity.getGeojsonPath());
+            String path = entity.getGeojsonPath();
+            deleteFolder(path, entity);
         }
 
         if (entity.getSlicePath() != null) {
@@ -134,6 +138,16 @@ public class VectorServerImpl implements VectorServer {
         return new R(200, MsgCode.SUCCESS);
     }
 
+
+    // 以目录形式删除
+    private void deleteFolder(String path, OutputFileEntity entity){
+        String directory = entity.getDirectory();
+        int length = directory.length();
+        path = path.substring(0, path.lastIndexOf(directory)+length);
+        log.warn("delete vector file: {}", path);
+        FileUtils.delFolder(path);
+    }
+
 //    @Override
 //    public R uploadFile(MultipartFile file, String coord) {
 //        log.warn("run uploadFile");
@@ -390,11 +404,10 @@ public class VectorServerImpl implements VectorServer {
 
     public static void main(String[] args) throws IOException {
 
-        String inPath = "F:\\test\\clip";
-        String outPath = "F:\\test\\copy";
+        String inPath = "F:\\test\\clip\\aaa\\wwww";
+        String outPath = "F:\\test\\copy\\aaa\\123.com";
+        System.out.println(inPath.substring(0, inPath.lastIndexOf("aaa") + 3));
+        System.out.println(outPath.substring(0, outPath.lastIndexOf("aaa") + 3));
 
-//        FileUtils.base64ToFileWriter(inPath, outPath);
-        org.apache.commons.io.FileUtils.copyFileToDirectory(new File(inPath), new File(outPath));
-//        org.apache.commons.io.FileUtils.
     }
 }

+ 1 - 1
src/main/resources/application.properties

@@ -1,7 +1,7 @@
 server.port=8082
 
 # file multipart
-spring.profiles.active=pro
+spring.profiles.active=uat
 spring.servlet.multipart.enabled=true
 spring.servlet.multipart.max-file-size=51200MB
 spring.servlet.multipart.max-request-size=51200MB