【fix sonar】 CommonController.java 文件

This commit is contained in:
tianwenbo
2023-03-07 17:12:03 +08:00
parent e64cf04292
commit 4b1d480380
@@ -64,7 +64,7 @@ public class CommonController {
@Value(value="${jero.fileSuffixLimits}") @Value(value="${jero.fileSuffixLimits}")
private String[] fileSuffixLimits; private String[] fileSuffixLimits;
private static String UTF8 ="UTF-8"; private static final String UTF8 ="UTF-8";
/** /**
* @Author 政辉 * @Author 政辉
@@ -176,7 +176,7 @@ public class CommonController {
fileName = ossFile.getFileName(); fileName = ossFile.getFileName();
inputStream = MinioUtil.getMinioFile(MinioUtil.getBucketName(), url); inputStream = MinioUtil.getMinioFile(MinioUtil.getBucketName(), url);
} }
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes(UTF8),StandardCharsets.ISO_8859_1)); response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes(StandardCharsets.UTF_8),StandardCharsets.ISO_8859_1));
response.setContentType("application/force-download");// 设置强制下载不打开 response.setContentType("application/force-download");// 设置强制下载不打开
outputStream = response.getOutputStream(); outputStream = response.getOutputStream();
byte[] buf = new byte[1024]; byte[] buf = new byte[1024];
@@ -311,7 +311,7 @@ public class CommonController {
throw new RuntimeException("文件["+imgPath+"]不存在.."); throw new RuntimeException("文件["+imgPath+"]不存在..");
} }
response.setContentType("application/force-download");// 设置强制下载不打开 response.setContentType("application/force-download");// 设置强制下载不打开
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes(UTF8), StandardCharsets.ISO_8859_1)); response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
inputStream = new BufferedInputStream(new FileInputStream(filePath)); inputStream = new BufferedInputStream(new FileInputStream(filePath));
outputStream = response.getOutputStream(); outputStream = response.getOutputStream();
byte[] buf = new byte[1024]; byte[] buf = new byte[1024];