From 98992b3d76c6cfd5c4de5fdcd7d14911e8d467e6 Mon Sep 17 00:00:00 2001 From: gaoxiongzaq Date: Sun, 23 Apr 2023 11:25:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9:?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=94=9F=E6=88=90=E7=9A=84PDF=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20=E6=96=87=E4=BB=B6=E5=90=8D=E7=A7=B0=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=96=87=E4=BB=B6=E5=90=8E=E7=BC=80=20=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E7=94=9F=E6=88=90=E5=90=8C=E5=90=8D=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/keking/service/impl/CadFilePreviewImpl.java | 3 ++- .../java/cn/keking/service/impl/OfficeFilePreviewImpl.java | 4 ++-- .../main/java/cn/keking/service/impl/TiffFilePreviewImpl.java | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/cn/keking/service/impl/CadFilePreviewImpl.java b/server/src/main/java/cn/keking/service/impl/CadFilePreviewImpl.java index 42b9c1a5..9a71cb2a 100644 --- a/server/src/main/java/cn/keking/service/impl/CadFilePreviewImpl.java +++ b/server/src/main/java/cn/keking/service/impl/CadFilePreviewImpl.java @@ -40,7 +40,8 @@ public class CadFilePreviewImpl implements FilePreview { String baseUrl = BaseUrlFilter.getBaseUrl(); boolean forceUpdatedCache=fileAttribute.forceUpdatedCache(); String fileName = fileAttribute.getName(); - String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + "pdf"; + String suffix = fileAttribute.getSuffix(); + String pdfName = fileName.substring(0, fileName.lastIndexOf(".")) + suffix +"." + "pdf" ; //生成文件添加类型后缀 防止同名文件 String outFilePath = FILE_DIR + pdfName; // 判断之前是否已转换过,如果转换过,直接返回,否则执行转换 if (forceUpdatedCache || !fileHandlerService.listConvertedFiles().containsKey(pdfName) || !ConfigConstants.isCacheEnabled()) { diff --git a/server/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java b/server/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java index ecd0f6b4..b88de064 100644 --- a/server/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java +++ b/server/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java @@ -49,8 +49,8 @@ public class OfficeFilePreviewImpl implements FilePreview { String filePassword = fileAttribute.getFilePassword(); boolean forceUpdatedCache=fileAttribute.forceUpdatedCache(); String userToken = fileAttribute.getUserToken(); - boolean isHtml = suffix.equalsIgnoreCase("xls") || suffix.equalsIgnoreCase("xlsx") || suffix.equalsIgnoreCase("csv") || suffix.equalsIgnoreCase("xlsm") || suffix.equalsIgnoreCase("xlt") || suffix.equalsIgnoreCase("xltm") || suffix.equalsIgnoreCase("et") || suffix.equalsIgnoreCase("ett") || suffix.equalsIgnoreCase("xlam"); - String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + (isHtml ? "html" : "pdf"); + boolean isHtml = suffix.equalsIgnoreCase("xls") || suffix.equalsIgnoreCase("xlsx") || suffix.equalsIgnoreCase("csv") || suffix.equalsIgnoreCase("xlsm") || suffix.equalsIgnoreCase("xlt") || suffix.equalsIgnoreCase("xltm") || suffix.equalsIgnoreCase("et") || suffix.equalsIgnoreCase("ett") || suffix.equalsIgnoreCase("xlam"); + String pdfName = fileName.substring(0, fileName.lastIndexOf(".") ) + suffix +"." +(isHtml ? "html" : "pdf"); //生成文件添加类型后缀 防止同名文件 String cacheFileName = userToken == null ? pdfName : userToken + "_" + pdfName; String outFilePath = FILE_DIR + cacheFileName; if (forceUpdatedCache|| !fileHandlerService.listConvertedFiles().containsKey(pdfName) || !ConfigConstants.isCacheEnabled()) { diff --git a/server/src/main/java/cn/keking/service/impl/TiffFilePreviewImpl.java b/server/src/main/java/cn/keking/service/impl/TiffFilePreviewImpl.java index 8d9beaba..d00fb505 100644 --- a/server/src/main/java/cn/keking/service/impl/TiffFilePreviewImpl.java +++ b/server/src/main/java/cn/keking/service/impl/TiffFilePreviewImpl.java @@ -39,6 +39,7 @@ public class TiffFilePreviewImpl implements FilePreview { String baseUrl = BaseUrlFilter.getBaseUrl(); String tifPreviewType = ConfigConstants.getTifPreviewType(); String tifOnLinePreviewType = fileAttribute.getTifPreviewType(); + String suffix = fileAttribute.getSuffix(); boolean forceUpdatedCache=fileAttribute.forceUpdatedCache(); if (StringUtils.hasText(tifOnLinePreviewType)) { tifPreviewType = tifOnLinePreviewType; @@ -47,7 +48,7 @@ public class TiffFilePreviewImpl implements FilePreview { model.addAttribute("currentUrl", url); return TIFF_FILE_PREVIEW_PAGE; } else if ("jpg".equalsIgnoreCase(tifPreviewType) || "pdf".equalsIgnoreCase(tifPreviewType)) { - String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + "pdf"; + String pdfName = fileName.substring(0, fileName.lastIndexOf(".")) + suffix +"." + "pdf" ; //生成文件添加类型后缀 防止同名文件 String jpgName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + "jpg"; String strLocalTif = fileDir + fileName; String outFilePath = fileDir + pdfName; From 37d4a1b7c44731e2d67b01f769f448b2f824a288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E9=9B=84?= Date: Mon, 24 Apr 2023 05:51:31 +0000 Subject: [PATCH 2/2] =?UTF-8?q?update=20server/src/main/java/cn/keking/ser?= =?UTF-8?q?vice/impl/TiffFilePreviewImpl.java.=20=E5=90=8C=E5=90=8D?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8D=E5=90=8C=E7=B1=BB=E5=9E=8B=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 高雄 --- .../main/java/cn/keking/service/impl/TiffFilePreviewImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/cn/keking/service/impl/TiffFilePreviewImpl.java b/server/src/main/java/cn/keking/service/impl/TiffFilePreviewImpl.java index d00fb505..2500a23c 100644 --- a/server/src/main/java/cn/keking/service/impl/TiffFilePreviewImpl.java +++ b/server/src/main/java/cn/keking/service/impl/TiffFilePreviewImpl.java @@ -49,7 +49,7 @@ public class TiffFilePreviewImpl implements FilePreview { return TIFF_FILE_PREVIEW_PAGE; } else if ("jpg".equalsIgnoreCase(tifPreviewType) || "pdf".equalsIgnoreCase(tifPreviewType)) { String pdfName = fileName.substring(0, fileName.lastIndexOf(".")) + suffix +"." + "pdf" ; //生成文件添加类型后缀 防止同名文件 - String jpgName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + "jpg"; + String jpgName = fileName.substring(0, fileName.lastIndexOf(".")) + suffix +"." + "jpg" ; //生成文件添加类型后缀 防止同名文件 String strLocalTif = fileDir + fileName; String outFilePath = fileDir + pdfName; if ("pdf".equalsIgnoreCase(tifPreviewType)) {