update server/src/main/java/cn/keking/service/impl/CommonPreviewImpl.java.

压缩文件无法预览问题修复

Signed-off-by: 马云 <12845730+jack-ma2023@user.noreply.gitee.com>
This commit is contained in:
马云 2025-05-18 11:42:42 +00:00 committed by Gitee
parent 6746325bf2
commit af53518be2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -33,13 +33,18 @@ public class CommonPreviewImpl implements FilePreview {
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
// 不是http开头浏览器不能直接访问需下载到本地
if (url != null && !url.toLowerCase().startsWith("http")) {
ReturnResponse<String> response = DownloadUtils.downLoad(fileAttribute, null);
if (response.isFailure()) {
return otherFilePreview.notSupportedFile(model, fileAttribute, response.getMsg());
String originFilePath = "";
if(fileAttribute.getCompressFile()) {
originFilePath = fileAttribute.getOriginFilePath();
} else {
String file = fileHandlerService.getRelativePath(response.getContent());
model.addAttribute("currentUrl", file);
ReturnResponse<String> response = DownloadUtils.downLoad(fileAttribute, null);
if (response.isFailure()) {
return otherFilePreview.notSupportedFile(model, fileAttribute, response.getMsg());
}
originFilePath = response.getContent();
}
String file = fileHandlerService.getRelativePath(originFilePath);
model.addAttribute("currentUrl", file);
} else {
model.addAttribute("currentUrl", url);
}