相对路径返回

beetlsql3-dev
Mlxa0324 2 years ago
parent ba0a66e80d
commit a46b58529a

@ -314,18 +314,21 @@ public class FileEntity extends BaseEntity {
*/
public static void tryConvertPDF(FileEntity fileEntity) {
try {
if (null != fileEntity && isCreatePdf(fileEntity.getAbsoluteUrl())) {
if (null != fileEntity && isCreatePdf(fileEntity.getUrl())) {
// 相对路径
String relativeUrl = fileEntity.getUrl();
// 绝对路径
String absoluteUrl = fileEntity.getAbsoluteUrl();
BufferedInputStream inputStream = FileUtil.getInputStream(absoluteUrl);
// 同名文件多生成一个pdf文件
String pdfName = absoluteUrl.replaceAll("\\.[^\\.]+", ".pdf");
String relativePdfName = relativeUrl.replaceAll("\\.[^\\.]+", ".pdf");
FileOutputStream outputStream = new FileOutputStream(pdfName);
// 根据类型来转换成为pdf
boolean convertedSuccess = PDFConverUtil.convertToPDFByFileNameSuffix(absoluteUrl, inputStream, outputStream);
if(convertedSuccess) {
// 转换成功,则返回给前端
fileEntity.set("cvPDFAbsoluteUrl", pdfName);
fileEntity.set("cvPDFUrl", relativePdfName);
}
}
}catch (IOException e) {

Loading…
Cancel
Save