优化:去除可能导致文件不更新的缓存
parent
03cc185085
commit
41a72798d9
|
@ -54,21 +54,15 @@ public class OfficeFilePreviewImpl implements FilePreview {
|
||||||
// 判断之前是否已转换过,如果转换过,直接返回,否则执行转换
|
// 判断之前是否已转换过,如果转换过,直接返回,否则执行转换
|
||||||
if (!fileUtils.listConvertedFiles().containsKey(pdfName) || !ConfigConstants.isCacheEnabled()) {
|
if (!fileUtils.listConvertedFiles().containsKey(pdfName) || !ConfigConstants.isCacheEnabled()) {
|
||||||
String filePath = fileDir + fileName;
|
String filePath = fileDir + fileName;
|
||||||
if (!new File(filePath).exists()) {
|
ReturnResponse<String> response = downloadUtils.downLoad(fileAttribute, null);
|
||||||
ReturnResponse<String> response = downloadUtils.downLoad(fileAttribute, null);
|
if (0 != response.getCode()) {
|
||||||
if (0 != response.getCode()) {
|
model.addAttribute("fileType", suffix);
|
||||||
model.addAttribute("fileType", suffix);
|
model.addAttribute("msg", response.getMsg());
|
||||||
model.addAttribute("msg", response.getMsg());
|
return "fileNotSupported";
|
||||||
return "fileNotSupported";
|
|
||||||
}
|
|
||||||
filePath = response.getContent();
|
|
||||||
}
|
}
|
||||||
|
filePath = response.getContent();
|
||||||
if (StringUtils.hasText(outFilePath)) {
|
if (StringUtils.hasText(outFilePath)) {
|
||||||
officeToPdf.openOfficeToPDF(filePath, outFilePath);
|
officeToPdf.openOfficeToPDF(filePath, outFilePath);
|
||||||
File f = new File(filePath);
|
|
||||||
if (f.exists()) {
|
|
||||||
f.delete();
|
|
||||||
}
|
|
||||||
if (isHtml) {
|
if (isHtml) {
|
||||||
// 对转换后的文件进行操作(改变编码方式)
|
// 对转换后的文件进行操作(改变编码方式)
|
||||||
fileUtils.doActionConvertedFile(outFilePath);
|
fileUtils.doActionConvertedFile(outFilePath);
|
||||||
|
|
|
@ -44,15 +44,13 @@ public class PdfFilePreviewImpl implements FilePreview{
|
||||||
String outFilePath = fileDir + pdfName;
|
String outFilePath = fileDir + pdfName;
|
||||||
if (OfficeFilePreviewImpl.OFFICE_PREVIEW_TYPE_IMAGE.equals(officePreviewType) || OfficeFilePreviewImpl.OFFICE_PREVIEW_TYPE_ALLIMAGES.equals(officePreviewType)) {
|
if (OfficeFilePreviewImpl.OFFICE_PREVIEW_TYPE_IMAGE.equals(officePreviewType) || OfficeFilePreviewImpl.OFFICE_PREVIEW_TYPE_ALLIMAGES.equals(officePreviewType)) {
|
||||||
//当文件不存在时,就去下载
|
//当文件不存在时,就去下载
|
||||||
if (!new File(outFilePath).exists()) {
|
ReturnResponse<String> response = downloadUtils.downLoad(fileAttribute, fileName);
|
||||||
ReturnResponse<String> response = downloadUtils.downLoad(fileAttribute, fileName);
|
if (0 != response.getCode()) {
|
||||||
if (0 != response.getCode()) {
|
model.addAttribute("fileType", suffix);
|
||||||
model.addAttribute("fileType", suffix);
|
model.addAttribute("msg", response.getMsg());
|
||||||
model.addAttribute("msg", response.getMsg());
|
return "fileNotSupported";
|
||||||
return "fileNotSupported";
|
|
||||||
}
|
|
||||||
outFilePath = response.getContent();
|
|
||||||
}
|
}
|
||||||
|
outFilePath = response.getContent();
|
||||||
List<String> imageUrls = pdfUtils.pdf2jpg(outFilePath, pdfName, originUrl);
|
List<String> imageUrls = pdfUtils.pdf2jpg(outFilePath, pdfName, originUrl);
|
||||||
if (imageUrls == null || imageUrls.size() < 1) {
|
if (imageUrls == null || imageUrls.size() < 1) {
|
||||||
model.addAttribute("msg", "pdf转图片异常,请联系管理员");
|
model.addAttribute("msg", "pdf转图片异常,请联系管理员");
|
||||||
|
|
Loading…
Reference in New Issue