i am trying to display a pdf in my browser with spring. my problem is that the browser downloads the file instead of displaying it. this is my code:
@RequestMapping(value = "/download" , method=RequestMethod.GET , produces = "application/pdf")
public ResponseEntity<InputStreamResource> downloadPdf() throws IOException {
ClassPathResource pdfFile = new ClassPathResource("TMOBILE.pdf");
return ResponseEntity
.ok()
.contentLength(pdfFile.contentLength())
.contentType(
MediaType.parseMediaType("application/octet-stream"))
.body(new InputStreamResource(pdfFile.getInputStream()));
}
i am looking forward to your answers! thanks