中扬CRM客户关系管理系统
#
LSH
2023-12-01 09ee5added9d59e90310a2586e846137ea597b19
src/main/java/com/zy/crm/common/utils/FileSaveExampleUtil.java
@@ -1,6 +1,8 @@
package com.zy.crm.common.utils;
import java.io.*;
import com.zy.crm.manager.entity.PlanUrl;
import org.springframework.core.io.Resource;
import java.net.URLEncoder;
@@ -61,19 +63,19 @@
//        }
//    }
    public static void saveFile(MultipartFile file, String savePath) throws IOException {
        // 创建保存文件的目录(如果不存在)
        File directory = new File(savePath);
        if (!directory.exists()) {
            directory.mkdirs();
        }
        // 保存文件
        String fileName = file.getOriginalFilename();
        String filePath = savePath + fileName;
        File dest = new File(filePath);
        file.transferTo(dest);
    }
//    public static void saveFile(MultipartFile file, String savePath) throws IOException {
//        // 创建保存文件的目录(如果不存在)
//        File directory = new File(savePath);
//        if (!directory.exists()) {
//            directory.mkdirs();
//        }
//
//        // 保存文件
//        String fileName = file.getOriginalFilename();
//        String filePath = savePath + fileName;
//        File dest = new File(filePath);
//        file.transferTo(dest);
//    }
    public static void deleteFilesInDirectory(String directoryPath) {
        File directory = new File(directoryPath);
@@ -237,6 +239,7 @@
        private String name;
        private long size;
        private String path;
        private String userName;
        private boolean success;
        private String errorMessage;
@@ -246,12 +249,26 @@
            this.path = path;
        }
        public FileDTO(String name, long size, String path,String userName) {
            this.name = name;
            this.size = size;
            this.path = path;
            this.userName = userName;
        }
        public FileDTO(String name, long size) {
            this.name = name;
            this.size = size;
//            this.path = path;
        }
        public FileDTO(PlanUrl planUrl) {
            this.name = planUrl.getName();
            this.size = planUrl.getFileSize();
            this.path = planUrl.getUrl();
            this.userName = planUrl.getUserName();
        }
        public FileDTO(boolean success, String name, String errorMessage) {
            this.success = success;
            this.name = name;