About Springboot File Downloads

Asked 2 years ago, Updated 2 years ago, 92 views

I'm studying downloading files.

I'm looking at the English site, but I don't know what the answer is.

·Return ResponseEntity

return ResponseEntity.ok()
            .contentType(MediaType.parseMediaType(contentType))
            .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"resource.getFilename()+"\"")
            .body(resource);

https://www.callicoder.com/spring-boot-file-upload-download-rest-api-example/

·Void Return Case

ServletOutputStream outputStream=httpServletResponse.getOutputStram();

https://youtu.be/ryRQ6qXLLYM?t=4401

Either way, the result of the download seems to be the same.
I would appreciate it if you could let me know if you could refer to the website.

java spring-boot

2022-09-30 16:04

1 Answers

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.