2021-02-08 18:02:49 +08:00
|
|
|
package cn.keking.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.keking.model.FileAttribute;
|
|
|
|
|
import cn.keking.service.FilePreview;
|
2021-03-26 10:05:58 +08:00
|
|
|
import cn.keking.utils.WebUtils;
|
2021-02-08 18:02:49 +08:00
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.ui.Model;
|
2021-03-26 10:05:58 +08:00
|
|
|
import org.springframework.util.StringUtils;
|
2021-02-08 18:02:49 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* tiff 图片文件处理
|
|
|
|
|
* @author kl (http://kailing.pub)
|
|
|
|
|
* @since 2021/2/8
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class TiffFilePreviewImpl implements FilePreview {
|
|
|
|
|
|
|
|
|
|
private final PictureFilePreviewImpl pictureFilePreview;
|
2021-03-26 10:05:58 +08:00
|
|
|
private static final String INITIALIZE_MEMORY_SIZE = "initializeMemorySize";
|
|
|
|
|
//默认初始化 50MB 内存
|
|
|
|
|
private static final long INITIALIZE_MEMORY_SIZE_VALUE_DEFAULT = 1024L * 1024 * 50;
|
2021-02-08 18:02:49 +08:00
|
|
|
|
|
|
|
|
public TiffFilePreviewImpl(PictureFilePreviewImpl pictureFilePreview) {
|
|
|
|
|
this.pictureFilePreview = pictureFilePreview;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
|
|
|
|
pictureFilePreview.filePreviewHandle(url,model,fileAttribute);
|
2021-03-26 10:05:58 +08:00
|
|
|
String fileSize = WebUtils.getUrlParameterReg(url,INITIALIZE_MEMORY_SIZE);
|
|
|
|
|
if(StringUtils.hasText(fileSize)){
|
|
|
|
|
model.addAttribute(INITIALIZE_MEMORY_SIZE,fileSize);
|
|
|
|
|
}else {
|
|
|
|
|
model.addAttribute(INITIALIZE_MEMORY_SIZE,Long.toString(INITIALIZE_MEMORY_SIZE_VALUE_DEFAULT));
|
|
|
|
|
}
|
2021-02-08 18:02:49 +08:00
|
|
|
return TIFF_FILE_PREVIEW_PAGE;
|
|
|
|
|
}
|
|
|
|
|
}
|