文件url采用base64加encodeURI双重编码,彻底解决各种奇葩文件名导致的下载异常

This commit is contained in:
chenkailing
2020-12-27 01:43:50 +08:00
committed by kl
parent aaf396fbc8
commit 486c09b24a
20 changed files with 113 additions and 1117 deletions

View File

@ -20,12 +20,8 @@ public class PictureFilePreviewImpl implements FilePreview {
private final FileHandlerService fileHandlerService;
private final DownloadUtils downloadUtils;
public PictureFilePreviewImpl(FileHandlerService fileHandlerService,
DownloadUtils downloadUtils) {
public PictureFilePreviewImpl(FileHandlerService fileHandlerService) {
this.fileHandlerService = fileHandlerService;
this.downloadUtils = downloadUtils;
}
@Override
@ -39,7 +35,7 @@ public class PictureFilePreviewImpl implements FilePreview {
}
// 不是http开头浏览器不能直接访问需下载到本地
if (url != null && !url.toLowerCase().startsWith("http")) {
ReturnResponse<String> response = downloadUtils.downLoad(fileAttribute, null);
ReturnResponse<String> response = DownloadUtils.downLoad(fileAttribute, null);
if (0 != response.getCode()) {
model.addAttribute("fileType", fileAttribute.getSuffix());
model.addAttribute("msg", response.getMsg());