Repository
// 'doc' is a blob type in oracle table
@Query(value = "select doc from watever where ROWNUM = 1", nativeQuery = true)
public byte[] findWatever();
Controller
byte[] reponse = dossierHypothecaireRepository.findWatever();
HttpHeaders headers = new HttpHeaders();
headers.setContentLength(reponse.length);
headers.setContentDispositionFormData("attachment", "out.pdf");
headers.setContentType(MediaType.parseMediaType("application/pdf"));
return new ResponseEntity<>(reponse, headers, HttpStatus.OK);
Problem
When I call this controller from a browser and want to display the pdf I get "pdf wont display" or "corrupt file"
I tried with many differents pdfs, browsers and pdfreaders: same error.
=> the problem comes from my code I think.
Edit additional information: The file I put in base for my test is : 430 ko The downloaded file from the browser is : 420 ko