!110 功能修改:调整生成的PDF文件 文件名称添加文件后缀 防止生成同名文件

Merge pull request !110 from 高雄/rename.a.file
pull/111/MERGE
kailing 2 years ago committed by Gitee
commit ae55f53325
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -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()) {

@ -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()) {

@ -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,8 +48,8 @@ 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 jpgName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + "jpg";
String pdfName = fileName.substring(0, fileName.lastIndexOf(".")) + suffix +"." + "pdf" ; //生成文件添加类型后缀 防止同名文件
String jpgName = fileName.substring(0, fileName.lastIndexOf(".")) + suffix +"." + "jpg" ; //生成文件添加类型后缀 防止同名文件
String strLocalTif = fileDir + fileName;
String outFilePath = fileDir + pdfName;
if ("pdf".equalsIgnoreCase(tifPreviewType)) {

Loading…
Cancel
Save