zhijiezhao 2 yıl önce
ebeveyn
işleme
095026334c

+ 8 - 2
src/main/java/com/caimei/config/FastDfsClient.java

@@ -4,6 +4,7 @@ import com.github.tobato.fastdfs.domain.StorePath;
 import com.github.tobato.fastdfs.proto.storage.DownloadByteArray;
 import com.github.tobato.fastdfs.service.FastFileStorageClient;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,6 +17,7 @@ import java.io.*;
  * @date 2021/5/14
  */
 @Component
+@Slf4j
 public class FastDfsClient {
 
     @Autowired
@@ -49,7 +51,11 @@ public class FastDfsClient {
     }
 
     public void deleteFile(String storagePath) {
-        String filepath = storagePath.substring(storagePath.lastIndexOf("group1/") + 7);
-        storageClient.deleteFile("group1", filepath);
+        try {
+            String filepath = storagePath.substring(storagePath.lastIndexOf("group1/") + 7);
+            storageClient.deleteFile("group1", filepath);
+        } catch (Exception e) {
+            log.error("删除失败!-------------》" + e);
+        }
     }
 }