|
|
@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component; |
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.*; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.nio.file.Files; |
|
|
|
|
|
|
|
/** |
|
|
@@ -67,15 +68,15 @@ public class MhXchxFileHelper { |
|
|
|
return JSONUtil.toJsonStr(retFileInfo); |
|
|
|
} |
|
|
|
|
|
|
|
public void exportReport(String reportFile, HttpServletResponse response){ |
|
|
|
public void exportReport(String reportFile, HttpServletResponse response) throws UnsupportedEncodingException { |
|
|
|
if (StrUtils.isBlank(reportFile)) { |
|
|
|
throw BizException.wrap("信创报告文件不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
File file = mhFileClient.downloadToTmpFile(reportFile); |
|
|
|
// 设置响应的内容类型和头信息 |
|
|
|
response.setContentType("application/octet-stream"); |
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=\"" + file.getName() + "\""); |
|
|
|
response.setContentType("application/pdf"); |
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=\"" + URLEncoder.encode(file.getName(),"utf-8") + "\""); |
|
|
|
|
|
|
|
// 使用ServletOutputStream写文件内容 |
|
|
|
try (InputStream in = Files.newInputStream(file.toPath()); |
|
|
|