diff --git a/src/main/java/com/xkrs/controller/FileController.java b/src/main/java/com/xkrs/controller/FileController.java index 1e63f62..9fbf6a7 100644 --- a/src/main/java/com/xkrs/controller/FileController.java +++ b/src/main/java/com/xkrs/controller/FileController.java @@ -40,7 +40,7 @@ public class FileController { * @return */ @PostMapping("/uploadFileMore") - public String uploadFileMore(MultipartFile[] files){ + public String uploadFileMore(MultipartFile[] files) throws Exception { Locale locale = LocaleContextHolder.getLocale(); if (null == files || files.length == 0){ return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "result or fileType is null", locale); @@ -52,9 +52,11 @@ public class FileController { if(m == false){ return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "图片大小不能超过100M", locale); } + File file1 = fileFastDfs.multipartFileToFile(file); String dir = "fire_point"; - String info = fileFastDfs.uploadFile(file, dir); + String info = fileFastDfs.uploadFile(file1, dir); Map map = getUploadInfo(info); + file1.delete(); FilePath filePath = new FilePath(); filePath.setFilePath(map.get("path")); filePath.setFileName(map.get("fileName")); @@ -75,7 +77,7 @@ public class FileController { * @return */ @PostMapping("/uploadFile") - public String uploadFile(MultipartFile file){ + public String uploadFile(MultipartFile file) throws Exception { Locale locale = LocaleContextHolder.getLocale(); if (null == file){ return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "result or fileType is null", locale); @@ -84,9 +86,11 @@ public class FileController { if(m == false){ return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "图片大小不能超过100M", locale); } + File file1 = fileFastDfs.multipartFileToFile(file); String dir = "fire_point"; - String info = fileFastDfs.uploadFile(file, dir); + String info = fileFastDfs.uploadFile(file1, dir); Map map = getUploadInfo(info); + file1.delete(); FilePath filePath = new FilePath(); filePath.setFilePath(map.get("path")); filePath.setFileName(map.get("fileName"));