So I have a method
@GetMapping(
value = "/download/{fileId}",
produces = { MediaType.APPLICATION_OCTET_STREAM_VALUE }
)
public ResponseEntity<InputStreamResource> download(@Valid @PathVariable(value = "fileId") String fileId) {
InputStreamResource file = new InputStreamResource(service.download(fileId));
HttpHeaders headers = new HttpHeaders();
headers.setContentType(new MediaType(MediaType.APPLICATION_OCTET_STREAM, Charset.forName("UTF-8")));
headers.setContentDispositionFormData("attachment", fileId+".doc");
headers.add("Content-Transfer-Encoding", "binary");
return ResponseEntity.ok()
.headers(headers)
.body(file);
}
and when I hit the API from postman, it returns : enter image description here
How can I make the output readable and downloadable from postman?