TIF转换修改 1转换PDF保留缓存 代码精简优化

TIF转换修改 1转换PDF保留缓存 代码精简优化

Signed-off-by: 高雄 <admin@cxcp.com>
pull/84/head
高雄 2 years ago committed by Gitee
parent 75e568e15f
commit 2cd23b06f1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -7,7 +7,6 @@ import cn.keking.service.FileHandlerService;
import cn.keking.service.FilePreview; import cn.keking.service.FilePreview;
import cn.keking.utils.ConvertPicUtil; import cn.keking.utils.ConvertPicUtil;
import cn.keking.utils.DownloadUtils; import cn.keking.utils.DownloadUtils;
import cn.keking.utils.WebUtils;
import cn.keking.web.filter.BaseUrlFilter; import cn.keking.web.filter.BaseUrlFilter;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.ui.Model; import org.springframework.ui.Model;
@ -32,12 +31,7 @@ public class TiffFilePreviewImpl implements FilePreview {
this.fileHandlerService = fileHandlerService; this.fileHandlerService = fileHandlerService;
this.otherFilePreview = otherFilePreview; this.otherFilePreview = otherFilePreview;
} }
private static final String INITIALIZE_MEMORY_SIZE = "initializeMemorySize";
//默认初始化 50MB 内存
private static final long INITIALIZE_MEMORY_SIZE_VALUE_DEFAULT = 1024L * 1024 * 50;
private final String fileDir = ConfigConstants.getFileDir(); private final String fileDir = ConfigConstants.getFileDir();
@Override @Override
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) { public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
String fileName = fileAttribute.getName(); String fileName = fileAttribute.getName();
@ -48,12 +42,7 @@ public class TiffFilePreviewImpl implements FilePreview {
tifPreviewType = tifOnLinePreviewType; tifPreviewType = tifOnLinePreviewType;
} }
if ("tif".equalsIgnoreCase(tifPreviewType)) { if ("tif".equalsIgnoreCase(tifPreviewType)) {
String fileSize = WebUtils.getUrlParameterReg(url, INITIALIZE_MEMORY_SIZE); model.addAttribute("currentUrl", url);
if (StringUtils.hasText(fileSize)) {
model.addAttribute(INITIALIZE_MEMORY_SIZE, fileSize);
} else {
model.addAttribute(INITIALIZE_MEMORY_SIZE, Long.toString(INITIALIZE_MEMORY_SIZE_VALUE_DEFAULT));
}
return TIFF_FILE_PREVIEW_PAGE; return TIFF_FILE_PREVIEW_PAGE;
} else if ("jpg".equalsIgnoreCase(tifPreviewType) || "pdf".equalsIgnoreCase(tifPreviewType)) { } else if ("jpg".equalsIgnoreCase(tifPreviewType) || "pdf".equalsIgnoreCase(tifPreviewType)) {
String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + "pdf"; String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + "pdf";

Loading…
Cancel
Save