From b9252fa09104c70ee90a3a380b45ffa1048b1aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E5=AE=87?= <2433098676@qq.com> Date: Tue, 15 Aug 2023 11:04:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E8=B4=A8=E4=B8=8A=E4=BC=A0=E5=88=B0?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/glxp/api/upload/uploadController.java | 26 +++++++++++-------- src/main/resources/application-dev.yml | 4 ++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/glxp/api/upload/uploadController.java b/src/main/java/com/glxp/api/upload/uploadController.java index e8bc5afe..f950e22d 100644 --- a/src/main/java/com/glxp/api/upload/uploadController.java +++ b/src/main/java/com/glxp/api/upload/uploadController.java @@ -26,6 +26,10 @@ public class uploadController { @Value("${file_path}") private String filePath; + @Value("${file_url}") + private String fileUrl; + @Value("${file_lpath}") + private String fileLpath; @Value("${minio_path}") private String minioPath; @Value("${minio_url}") @@ -121,23 +125,23 @@ public class uploadController { return ResultVOUtils.error(ResultEnum.DATA_ERROR, "上传文件只能是 jpg,png,doc,pdf 格式"); } String newName = UUID.randomUUID() + fileType;//生成新文件名 - String savePath = minioPath + "/register/file/" + type; - String fileFullName = savePath + "/" + newName; + String savePath = filePath + "/register/" + type; + String savePath1 = fileLpath + "?type=" + type; -// File file1 = new File(savePath); -// if (!file1.exists()) {// 判断目录是否存在 -// file1.mkdirs();// 创建多层目录 -// } -// file1 = new File(savePath + "/" + newName); + File file1 = new File(savePath); + if (!file1.exists()) {// 判断目录是否存在 + file1.mkdirs();// 创建多层目录 + } + file1 = new File(savePath + "/" + newName); try { -// file.transferTo(file1); - MinioUtil.uploadFile(fileFullName, file); + file.transferTo(file1); +// MinioUtil.uploadFile(fileFullName, file); Map rMap = new HashMap<>(); rMap.put("msg", "上传成功"); - rMap.put("name", minioUrl + fileFullName); + rMap.put("name", fileUrl + savePath1 + "&name=" + newName); rMap.put("type", type); return ResultVOUtils.success(rMap); - } catch (Exception e) { + } catch (IOException e) { e.printStackTrace(); } return ResultVOUtils.error(ResultEnum.DATA_ERROR, "上传失败"); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index ef8e6776..3b0782df 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -47,7 +47,9 @@ logging: level: com.glxp.api.dao: debug -file_path: d:/udi/udiwms/udiwmsfile/ +file_path: D:/udi/udiwms/udiwmsfile/ +file_url: http://127.0.0.1:9993 +file_lpath: /udiwms/image/register/file/getImage minio_path: /udi minio_url: http://139.9.219.60:9000 err_path: d:/udi/udiwms/err/