Browse Source

修改下载变更记录模板接口

fengyanjie 3 years ago
parent
commit
ead3569a07

+ 2 - 20
dmp-rwd-edit/src/main/java/com/persagy/dmp/rwd/edit/controller/DownloadController.java

@@ -44,31 +44,13 @@ public class DownloadController {
         InputStream resourceAsStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("siatic/file/批量上传变更记录模板2.xlsx");
         String fileName = "批量上传变更记录模板.xlsx";
         InputStream inputStream = new BufferedInputStream(resourceAsStream);
-//        @SuppressWarnings("resource")
-//        Workbook workbook = new HSSFWorkbook(inputStream);
-//        String userAgent = req.getHeader("User-Agent");
-//        if (userAgent.contains("MSIE") || userAgent.contains("Trident")) {
-//            fileName = new String(fileName.getBytes("gbk"), "utf-8");
-//        } else {
-//            // 非IE浏览器的处理:
-//            fileName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
-//        }
-//        response.setHeader("Content-disposition", "attachment; filename=" + fileName);
-//        response.setContentType("application/octet-stream;charset=utf-8");
-//        response.setCharacterEncoding("UTF-8");
-//        // 将流中内容写出去
-//        OutputStream outputStream = response.getOutputStream();
-//        workbook.write(outputStream);
-//        outputStream.flush();
-//        outputStream.close();
-
-
         OutputStream out = null;
         try {
             String resultFileName = URLEncoder.encode(fileName, "UTF-8");
             resp.reset();// 清空输出流
             resp.setCharacterEncoding("UTF-8");
-            resp.setHeader("Content-disposition", "attachment; filename=" + resultFileName);
+//            resp.setHeader("Content-disposition", "attachment; filename=" + resultFileName);
+            resp.setHeader("Content-Length", String.valueOf(resourceAsStream.available()));
             resp.setContentType("application/txt");
             out = resp.getOutputStream();
             int len;