修复流的方法错误 ,修复跨域脚本缺少BASE64 (#423)
* 修复office下载方法中 错误 * 更新OFD解析效果,修复禁止trace请求无效问题,其他压缩包修复 * 修复压缩包 缓存BUG * 限制某些特殊文件上传 * 修复OFFICE文件密码检查关闭流 上传文件关闭流 检查PDF文件是否存在 * 特殊符号的支持 Co-authored-by: gaoxiongzaq <admin@cxcp.com>
This commit is contained in:
@ -191,6 +191,9 @@ public class FileHandlerService {
|
||||
}
|
||||
try {
|
||||
File pdfFile = new File(pdfFilePath);
|
||||
if (!pdfFile.exists()) {
|
||||
return null;
|
||||
}
|
||||
PDDocument doc = PDDocument.load(pdfFile);
|
||||
int pageCount = doc.getNumberOfPages();
|
||||
PDFRenderer pdfRenderer = new PDFRenderer(doc);
|
||||
@ -273,11 +276,6 @@ public class FileHandlerService {
|
||||
if (url.contains("?fileKey=")) {
|
||||
attribute.setSkipDownLoad(true);
|
||||
}
|
||||
String urlStrr = url.toLowerCase(); //转换为小写对比
|
||||
boolean wjl = WebUtils.kuayu("&fullfilename=", urlStrr); //判断是否启用文件流
|
||||
if(wjl){
|
||||
url = url.substring(0,url.lastIndexOf("&")); //删除添加的文件流内容
|
||||
}
|
||||
url = WebUtils.encodeUrlFileName(url);
|
||||
fileName = KkFileUtils.htmlEscape(fileName); //文件名处理
|
||||
attribute.setType(type);
|
||||
|
||||
@ -40,6 +40,12 @@ public class CompressFilePreviewImpl implements FilePreview {
|
||||
}
|
||||
String filePath = response.getContent();
|
||||
fileTree = compressFileReader.unRar(filePath, fileName);
|
||||
if (fileTree != null && !"null".equals(fileTree)) {
|
||||
if (ConfigConstants.isCacheEnabled()) {
|
||||
// 加入缓存
|
||||
fileHandlerService.addConvertedFile(fileName, fileTree);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fileTree = fileHandlerService.getConvertedFile(fileName);
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -50,7 +51,7 @@ public class OfficeFilePreviewImpl implements FilePreview {
|
||||
String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + (isHtml ? "html" : "pdf");
|
||||
String cacheFileName = userToken == null ? pdfName : userToken + "_" + pdfName;
|
||||
String outFilePath = FILE_DIR + cacheFileName;
|
||||
|
||||
if ( !fileHandlerService.listConvertedFiles().containsKey(pdfName) || !ConfigConstants.isCacheEnabled()) {
|
||||
// 下载远程文件到本地,如果文件在本地已存在不会重复下载
|
||||
ReturnResponse<String> response = DownloadUtils.downLoad(fileAttribute, fileName);
|
||||
if (response.isFailure()) {
|
||||
@ -115,11 +116,11 @@ public class OfficeFilePreviewImpl implements FilePreview {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!isHtml && baseUrl != null && (OFFICE_PREVIEW_TYPE_IMAGE.equals(officePreviewType) || OFFICE_PREVIEW_TYPE_ALL_IMAGES.equals(officePreviewType))) {
|
||||
return getPreviewType(model, fileAttribute, officePreviewType, baseUrl, cacheFileName, outFilePath, fileHandlerService, OFFICE_PREVIEW_TYPE_IMAGE, otherFilePreview);
|
||||
}
|
||||
|
||||
cacheFileName = URLEncoder.encode(cacheFileName).replaceAll("\\+", "%20");
|
||||
model.addAttribute("pdfUrl", cacheFileName);
|
||||
return isHtml ? EXEL_FILE_PREVIEW_PAGE : PDF_FILE_PREVIEW_PAGE;
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import cn.keking.web.filter.BaseUrlFilter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -73,6 +74,7 @@ public class PdfFilePreviewImpl implements FilePreview {
|
||||
fileHandlerService.addConvertedFile(pdfName, fileHandlerService.getRelativePath(outFilePath));
|
||||
}
|
||||
} else {
|
||||
pdfName = URLEncoder.encode(pdfName).replaceAll("\\+", "%20");
|
||||
model.addAttribute("pdfUrl", pdfName);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user