Hey guys¡ I have one several problem. Perhaps it could be solver over there, but I can't find the solution.
I'm saving in request session the file that the user upload to the server. User's can upload .pdf, .doc, .xls and image extensions.
Until now, I only can return images, but no pdf or doc files. The problem appears when in my download controller, I have to set the headers for the file and it depends on the file I get from the session. I dont know how especific that. Its the code:
@RequestMapping(value = "/api/previsualizarFacturaOriginal/{idFacturaOriginal}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)
public static ResponseEntity<byte[]> getImageFacturaOriginal(
final @PathVariable("idFacturaOriginal") String idFacturaOriginal,
final HttpServletRequest request) {
try {
//get object from the session
final byte[] file = (byte[]) request.getSession().getAttribute(
Naming.SESSION_PDF_FACTURA_ORIGINAL + idFacturaOriginal);
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.IMAGE_JPEG);
return new ResponseEntity<byte[]>(file, headers, HttpStatus.OK);
} catch (final Exception e) {
return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}