To make an InputStreamResource accessible from Postman, you will need to follow these steps:
@GetMapping(value = "/download", produces = MediaType.APPLICATION_PDF_VALUE)
public ResponseEntity<InputStreamResource> download() {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Disposition", "attachment; filename=example.pdf");
ByteArrayInputStream bis = new ByteArrayInputStream(createPdf());
InputStreamResource isr = new InputStreamResource(bis);
return ResponseEntity.ok()
.headers(headers)
.contentType(MediaType.APPLICATION_PDF)
.body(isr);
}
private byte[] createPdf() {
// create the PDF byte array
}
In Postman, make a GET request to the endpoint that returns the InputStreamResource. You should see the file download dialog box pop up.
Click "Save" to save the file to your computer. You should now have access to the file.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-02-10 11:00:00 +0000
Seen: 10 times
Last updated: Feb 15 '22
How can you create an OpenGL plot without relying on external libraries, starting from scratch?
How can I use iText7 to create a PDF that includes a pie chart?
How can I create a monitor in Datadog that includes multiple resources' metrics in one monitor?
Create a regular expression for the following format.
How to create GS1-128 using ZXing.Net?
Is it advisable to create event handlers in a separate method rather than inline all the time?
How to implement a leaderboard in Flutter?
How to create a plot using mplfinance and PyQt5 that includes a volume graph?