I tested the code in IE-11 , its work is great. See below ie code
@RequestMapping(value = "/downloadfile", method = RequestMethod.GET) @ResponseBody public void downloadfile(HttpServletRequest request, HttpServletResponse response) throws Exception { ServletOutputStream servletOutputStream = null; try { response.setContentType("application/octet-stream"); response.setHeader("Content-Disposition", "attachment; filename=downloadppt.pptx"); byte[] ppt = downloadFile(); servletOutputStream = response.getOutputStream(); servletOutputStream.write(ppt); } catch (Exception e) { throw e; } finally { servletOutputStream.flush(); servletOutputStream.close(); } }
Generate bytes from the saved pptx file.
public byte[] downloadFile() throws IOException { InputStream inputStream = new FileInputStream(new File("e:/testppt.pptx")); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); // Transfer bytes from source to destination byte[] buf = new byte[1024]; int len; while ((len = inputStream.read(buf)) > 0) { byteArrayOutputStream.write(buf, 0, len); } inputStream.close(); byteArrayOutputStream.close(); return byteArrayOutputStream.toByteArray(); }
To do this, you can download the pptx file. The code of hope will help you if you have any questions or doubts, we can discuss or any suggestions. thank you
source share