|
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.io.*;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -112,17 +113,18 @@ public class ParseEmailController{
|
|
|
public void downloadEmailFile(@RequestBody FileIdVO fileId,HttpServletResponse response, HttpServletRequest request){
|
|
|
EmailFileInfoVO emailFileInfoVO = parseEmailService.getEmailFileById(fileId.getFileId());
|
|
|
try {
|
|
|
- response.setContentType("application/octet-stream");
|
|
|
- response.addHeader("Content-Disposition", "attachment;filename=" + EncodeUtil.encodeUTF8(emailFileInfoVO.getFileName()));
|
|
|
- OutputStream outputStream = response.getOutputStream();
|
|
|
- FileUtils.copyFile(new File(emailFileInfoVO.getFilePath()),outputStream);
|
|
|
- outputStream.flush();
|
|
|
- outputStream.close();
|
|
|
- } catch (IOException e) {
|
|
|
+ throw new RuntimeException();
|
|
|
+// response.setContentType("application/octet-stream");
|
|
|
+// response.addHeader("Content-Disposition", "attachment;filename=" + EncodeUtil.encodeUTF8(emailFileInfoVO.getFileName()));
|
|
|
+// OutputStream outputStream = response.getOutputStream();
|
|
|
+// FileUtils.copyFile(new File(emailFileInfoVO.getFilePath()),outputStream);
|
|
|
+// outputStream.flush();
|
|
|
+// outputStream.close();
|
|
|
+ } catch (Exception e) {
|
|
|
logger.error(e.getMessage(),e);
|
|
|
try{
|
|
|
OutputStream outputStream = response.getOutputStream();
|
|
|
- FileUtils.copyFile(new File(emailFileInfoVO.getFilePath()),outputStream);
|
|
|
+ outputStream.write("网络链接中断,请重试".getBytes(StandardCharsets.UTF_8));
|
|
|
outputStream.flush();
|
|
|
outputStream.close();
|
|
|
}catch (Exception exception){
|