|
|
@@ -23,7 +23,6 @@ import me.zhengjie.base.util.StatusEnum.StepStatusEnum;
|
|
|
import me.zhengjie.application.bank.controller.vo.FileUploadVO;
|
|
|
import me.zhengjie.application.admin.controller.vo.FileVo;
|
|
|
import me.zhengjie.application.bank.controller.vo.ImageUploadVO;
|
|
|
-import me.zhengjie.base.config.AppConfigInfo;
|
|
|
import me.zhengjie.base.file.FileHandle;
|
|
|
import me.zhengjie.base.file.FileHandleVo;
|
|
|
|
|
|
@@ -36,7 +35,6 @@ import me.zhengjie.base.file.FileHandleVo;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
public class FileUploadUtil {
|
|
|
-
|
|
|
private static FileHandle fileHandle;
|
|
|
// 创建临时目录
|
|
|
private static String tempDir;
|
|
|
@@ -263,25 +261,6 @@ public class FileUploadUtil {
|
|
|
|
|
|
}
|
|
|
|
|
|
-// public static String saveHtml(String html, String businessNo) {
|
|
|
-// if (html == null) {
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-// String uploadPath = AppConfigInfo.APP_UPLOAD_PATH;
|
|
|
-// // 拼接文件路径
|
|
|
-// String fileName = UUIDGenerator.uuid() + ".html";
|
|
|
-// String imagePath = "no" + businessNo + "/" + fileName;
|
|
|
-// String filePath = uploadPath + imagePath;
|
|
|
-// try {
|
|
|
-// // File file, String data, Charset charset
|
|
|
-// FileUtils.writeStringToFile(new File(filePath), html, "UTF-8");
|
|
|
-// return imagePath;
|
|
|
-// } catch (IOException e) {
|
|
|
-// log.info("上传图片失败:" + e.getLocalizedMessage());
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
public static String saveHtml(String html, String businessNo) {
|
|
|
if (html == null) {
|
|
|
return null;
|
|
|
@@ -305,27 +284,6 @@ public class FileUploadUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// public static String saveHtml(String filePath, String html) {
|
|
|
-// if (html == null) {
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-// // 拼接文件路径
|
|
|
-//
|
|
|
-// try {
|
|
|
-// ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes("UTF-8"));
|
|
|
-// // File file, String data, Charset charset
|
|
|
-// FileHandleVo fileHandlevo = new FileHandleVo();
|
|
|
-// fileHandlevo.setFilePath(filePath);
|
|
|
-// fileHandlevo.setContentType("text/html");
|
|
|
-// fileHandlevo.setInputStream(bis);
|
|
|
-// fileHandle.uploadFileStream(fileHandlevo);
|
|
|
-// bis.close();
|
|
|
-// return filePath;
|
|
|
-// } catch (Exception e) {
|
|
|
-// log.error("上传图片失败:" + e.getLocalizedMessage());
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-// }
|
|
|
/**
|
|
|
* 上传文件通过文件的流
|
|
|
*
|
|
|
@@ -398,25 +356,6 @@ public class FileUploadUtil {
|
|
|
|
|
|
}
|
|
|
|
|
|
-// public static String savePdf(String html, String businessNo) {
|
|
|
-// if (html == null) {
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-//
|
|
|
-// String uploadPath = AppConfigInfo.APP_UPLOAD_PATH;
|
|
|
-// // 拼接文件路径
|
|
|
-// String fileName = UUIDGenerator.uuid() + ".pdf";
|
|
|
-// String path = "no" + businessNo + "/" + fileName;
|
|
|
-// String filePath = uploadPath + path;
|
|
|
-// try {
|
|
|
-// // File file, String data, Charset charset
|
|
|
-// HtmlConvertPdf.createPdfFile(html, filePath);
|
|
|
-// return path;
|
|
|
-// } catch (Exception e) {
|
|
|
-// log.info("转换pdf失败:" + e.getLocalizedMessage());
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-// }
|
|
|
/**
|
|
|
* Return the absolute temp dir for given web server.
|
|
|
*
|
|
|
@@ -436,7 +375,7 @@ public class FileUploadUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static String savePdf(String html, String businessNo) {
|
|
|
+ public static String savePdf(String html, String businessNo, HtmlConvertToPdf htmlConvertToPdf) {
|
|
|
if (html == null) {
|
|
|
return null;
|
|
|
}
|
|
|
@@ -448,7 +387,7 @@ public class FileUploadUtil {
|
|
|
InputStream inputStream = null;
|
|
|
try {
|
|
|
// File file, String data, Charset charset
|
|
|
- HtmlConvertPdf.converPdf(html, sourceFilePath);
|
|
|
+ htmlConvertToPdf.converPdf(html, sourceFilePath);
|
|
|
inputStream = new FileInputStream(sourceFilePath);
|
|
|
// 这里需要把转换完成的删除掉
|
|
|
String contentType = "application/pdf";
|
|
|
@@ -471,40 +410,6 @@ public class FileUploadUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static String createPdf(String html, String pdfPath) {
|
|
|
-
|
|
|
- if (html == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- String uploadPath = tempDir;
|
|
|
-
|
|
|
- String sourceFilePath = uploadPath + pdfPath;
|
|
|
- InputStream inputStream = null;
|
|
|
- try {
|
|
|
- // File file, String data, Charset charset
|
|
|
- HtmlConvertPdf.converPdf(html, sourceFilePath);
|
|
|
- inputStream = new FileInputStream(sourceFilePath);
|
|
|
- // 这里需要把转换完成的删除掉
|
|
|
- String contentType = "application/pdf";
|
|
|
- // 通过流上传
|
|
|
- // fileHandle.uploadFilePath(path, filePath, contentType);
|
|
|
- FileHandleVo fileHandlevo = new FileHandleVo();
|
|
|
- fileHandlevo.setFilePath(pdfPath);
|
|
|
- fileHandlevo.setSourceFilePath(sourceFilePath);
|
|
|
- fileHandlevo.setContentType(contentType);
|
|
|
- fileHandlevo.setInputStream(inputStream);
|
|
|
- fileHandle.uploadFileStream(fileHandlevo);
|
|
|
- IoUtil.close(inputStream);
|
|
|
- // 这个删除文件留给具体的上传处理
|
|
|
- FileUtils.deleteQuietly(new File(sourceFilePath));
|
|
|
- return pdfPath;
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("转换pdf失败:" + e.getLocalizedMessage());
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 产生图片预览
|
|
|
*
|