Browse Source

预警

dev_kxc
ljf 1 year ago
parent
commit
ddf8655b03
  1. 18
      jwtech-admin/src/main/java/com/kms/web/controller/common/CommonController.java

18
jwtech-admin/src/main/java/com/kms/web/controller/common/CommonController.java

@ -64,16 +64,20 @@ public class CommonController
String uploadType = JianweiConfig.getUploadType(); String uploadType = JianweiConfig.getUploadType();
if (uploadType.equals("disk")) { if (uploadType.equals("disk")) {
// 本地资源路径 // 本地资源路径
String localPath = JianweiConfig.getProfile(); // String localPath = JianweiConfig.getProfile();
// 数据库资源地址 // // 数据库资源地址
String downloadPath = localPath + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX); // 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;
// // 下载名称
// String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
response.setContentType("multipart/form-data"); response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", response.setHeader("Content-Disposition",
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName)); "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
FileUtils.writeBytes(downloadPath, response.getOutputStream()); FileUtils.writeBytes(filePath, response.getOutputStream());
} else { } else {
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");

Loading…
Cancel
Save