Files
file-online-preview/server/src/main/java/cn/keking/service/impl/PictureFilePreviewImpl.java
gaoxiongzaq deb91728d4 1.修复压缩包 二级目录无法解压问题 修改压缩包生成PDF路径
2.修复PDF 带密码缓存问题 新增PDF带密码缓存方法 userToken
3.精简OFFICE 转换代码
4.精简TIF转换代码 新增TIF转换图片缓存 修复tif错误文件不自动释放内存 等待其他修复
5.修复下载方法错 特殊符号下载错误
6.调整文件名 统一方法在FileHandlerService
7.新增判断文件名是否被URL转义
2023-10-23 17:06:05 +08:00

43 lines
1.4 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cn.keking.service.impl;
import cn.keking.model.FileAttribute;
import cn.keking.service.FileHandlerService;
import cn.keking.utils.KkFileUtils;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kl on 2018/1/17.
* Content :图片文件处理
*/
@Service
public class PictureFilePreviewImpl extends CommonPreviewImpl {
private final FileHandlerService fileHandlerService;
public PictureFilePreviewImpl(FileHandlerService fileHandlerService, OtherFilePreviewImpl otherFilePreview) {
super(fileHandlerService, otherFilePreview);
this.fileHandlerService = fileHandlerService;
}
@Override
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
url= KkFileUtils.htmlEscape(url);
List<String> imgUrls = new ArrayList<>();
imgUrls.add(url);
String fileKey = fileAttribute.getFileKey();
List<String> zipImgUrls = fileHandlerService.getImgCache(fileKey);
if (!CollectionUtils.isEmpty(zipImgUrls)) {
imgUrls.addAll(zipImgUrls);
}
// 不是http开头浏览器不能直接访问需下载到本地
super.filePreviewHandle(url, model, fileAttribute);
model.addAttribute("imgUrls", imgUrls);
return PICTURE_FILE_PREVIEW_PAGE;
}
}