fix: 企标计划xls导出接口解密报错
This commit is contained in:
+6
-1
@@ -5,6 +5,7 @@ import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.modules.docking.download.service.DownloadDecryptFileService;
|
||||
import com.jero.modules.docking.utils.IntekeyUtils;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -158,7 +159,8 @@ public class DownloadDecryptFileServiceImpl implements DownloadDecryptFileServic
|
||||
String fileName = "";
|
||||
String headerField = response.getHeader("Content-Disposition");
|
||||
|
||||
if (!StringUtils.isBlank(headerField) || headerField.contains("fileName=") || headerField.contains("filename=")){
|
||||
if (headerField != null &&
|
||||
(!StringUtils.isBlank(headerField) || headerField.contains("fileName=") || headerField.contains("filename="))){
|
||||
String name = "";
|
||||
if(headerField.contains("fileName=")){
|
||||
name = "fileName";
|
||||
@@ -166,6 +168,9 @@ public class DownloadDecryptFileServiceImpl implements DownloadDecryptFileServic
|
||||
name = "filename";
|
||||
}
|
||||
fileName = headerField.substring(headerField.lastIndexOf(name + "=") + 9);
|
||||
if (headerField.contains("filename*=UTF-8")){
|
||||
fileName = headerField.substring(headerField.lastIndexOf("filename*=UTF-8") + 17);
|
||||
}
|
||||
}else {
|
||||
fileName = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jero.modules.docking.utils;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
@@ -68,6 +69,10 @@ public class IntekeyUtils {
|
||||
File file = null;
|
||||
try {
|
||||
String originalFilename = multipartFile.getOriginalFilename();
|
||||
// 如果文件名中有特殊字符,则需要使用URLDecoder解析真正的文件名
|
||||
if (StrUtil.isNotBlank(originalFilename) && originalFilename.contains("%")) {
|
||||
originalFilename = java.net.URLDecoder.decode(originalFilename, "UTF-8");
|
||||
}
|
||||
int index = originalFilename.lastIndexOf(".");
|
||||
//String[] filename = originalFilename.split("\\.");
|
||||
file = File.createTempFile(originalFilename.substring(0, index), originalFilename.substring(index + 1));
|
||||
|
||||
Reference in New Issue
Block a user