I am trying to return a PowerPoint file asynchronously to the client from a Spring MVC @RequestMapping method using Apache POI's HSFL. However I can't get the file to download
Here's my code
@RequestMapping(value = "/downloadPPT", produces = "application/vnd.ms-powerpoint")
public @ResponseBody byte[] downloadPPT(HttpServletResponse response) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] bytes = null;
HSLFSlideShow ppt = new HSLFSlideShow();
// add first slide
HSLFSlide s1 = ppt.createSlide();
// add second slide
HSLFSlide s2 = ppt.createSlide();
// save changes in a file
FileOutputStream out = new FileOutputStream("slideshow.ppt");
ppt.write(outputStream);
out.close();
bytes = outputStream.toByteArray();
return bytes;
}
My response seems to be a byte-version of the ppt file I created, however the user doesn't get prompted to download the file. What am I doing wrong here?