在不下载文件的情况下,如何直接将文件直接转化成MultipartFile file 或者是 InputStream inputStream 类型,
或者是存在方法 直接就是MultipartFile file 类型
- Code: Select all
OutputStream out = null;
try {
String fileName = "exportWhitePaper-" +URLEncoder.encode(whitePaperTitle, "utf-8") + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".docx";
String headStr = "attachment; filename=\"" + fileName + "\"";
response.reset();
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", headStr);
out = response.getOutputStream();
doc.saveToStream(out, FileFormat.Docx);
//如何直接将文件直接转化成MultipartFile file 或者是 InputStream inputStream 类型
out.flush();
out.close();
} catch (Exception e) {
log.info("ExportWordUtil.whiteExportResponse:", e);
}finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}