From ddf8655b032e066bc132a24a87c7e9ef2f68ac8b Mon Sep 17 00:00:00 2001 From: ljf Date: Wed, 24 Apr 2024 18:19:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=A2=84=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/common/CommonController.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/jwtech-admin/src/main/java/com/kms/web/controller/common/CommonController.java b/jwtech-admin/src/main/java/com/kms/web/controller/common/CommonController.java index 03a4f8e1..5dbd9168 100644 --- a/jwtech-admin/src/main/java/com/kms/web/controller/common/CommonController.java +++ b/jwtech-admin/src/main/java/com/kms/web/controller/common/CommonController.java @@ -64,16 +64,20 @@ public class CommonController String uploadType = JianweiConfig.getUploadType(); if (uploadType.equals("disk")) { // 本地资源路径 - String localPath = JianweiConfig.getProfile(); - // 数据库资源地址 - String downloadPath = localPath + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX); - // 下载名称 - String downloadName = StringUtils.substringAfterLast(downloadPath, "/"); +// String localPath = JianweiConfig.getProfile(); +// // 数据库资源地址 +// String downloadPath = localPath + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX); + + String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); + String filePath = JianweiConfig.getDownloadPath() + fileName; + +// // 下载名称 +// String downloadName = StringUtils.substringAfterLast(downloadPath, "/"); response.setCharacterEncoding("utf-8"); response.setContentType("multipart/form-data"); response.setHeader("Content-Disposition", - "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName)); - FileUtils.writeBytes(downloadPath, response.getOutputStream()); + "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName)); + FileUtils.writeBytes(filePath, response.getOutputStream()); } else { response.setCharacterEncoding("utf-8"); From 4d95375acf35c7a32a9ea158313c641f628a30fe Mon Sep 17 00:00:00 2001 From: ljf Date: Thu, 25 Apr 2024 09:50:05 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=A2=84=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/common/CommonController.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/jwtech-pc/src/main/java/com/kms/web/controller/common/CommonController.java b/jwtech-pc/src/main/java/com/kms/web/controller/common/CommonController.java index 0cef855f..2a0db01b 100644 --- a/jwtech-pc/src/main/java/com/kms/web/controller/common/CommonController.java +++ b/jwtech-pc/src/main/java/com/kms/web/controller/common/CommonController.java @@ -61,22 +61,24 @@ public class CommonController { try { - String uploadType = JianweiConfig.getUploadType(); - if (uploadType.equals("disk")) { + // 本地资源路径 - String localPath = JianweiConfig.getProfile(); +// String localPath = JianweiConfig.getProfile(); // 数据库资源地址 - String downloadPath = localPath + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX); - // 下载名称 - String downloadName = StringUtils.substringAfterLast(downloadPath, "/"); +// String downloadPath = localPath + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX); +// // 下载名称 +// String downloadName = StringUtils.substringAfterLast(downloadPath, "/"); + String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); + String filePath = JianweiConfig.getDownloadPath() + fileName; + response.setCharacterEncoding("utf-8"); response.setContentType("multipart/form-data"); response.setHeader("Content-Disposition", - "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName)); - FileUtils.writeBytes(downloadPath, response.getOutputStream()); + "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName)); + FileUtils.writeBytes(filePath, response.getOutputStream()); } else { response.setCharacterEncoding("utf-8");