I am developing an application with Spring Boot 1.5.19, and in this application, file operations (upload/download) are one among some basic requirements.
For the upload feature, I have successfully implemented it for any type of file. However, for the download feature, when trying to download an image, the controller method works, but when I try to download, say .docx, .doc, .csv, or other extensions than what Spring Boot's MediaType offers, the controller method returns byte array and not downloading the file.
I read in some other questions that I need to specify the format of the file I want to download in the controller method such as @GetMapping("/file/{fileId}.docx"), but if I were to use this, then I think I would have so many controllers for each possible return type.
I hoped that I can define only one controller method for downloading any type of file as if I had to list all possible file extensions for each method, then what a waste of time it would be, and how dirty the code is.
Given these conditions and expectations, does anyone have any idea or solution for this? Any help would be appreciated.
Thanks a lot.
Aucun commentaire:
Enregistrer un commentaire