From aebf765b4282e86ac6737fafc1a6c30b18949c64 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G8BCEP0\\HP" <2037158277@qq.com> Date: Sat, 18 Sep 2021 13:44:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BB=A3=E7=A0=81=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xkrs/controller/FileController.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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"));