I would like to download a file while retaining the filename of the file.
I have:
@RequestMapping(value = "/downloadFile", method = RequestMethod.GET, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@ResponseBody
public FileSystemResource getFile(@RequestParam(value="filename") String filename) {
return new FileSystemResource(uploadDir + "/" + filename);
}
I can download the file but the filename I download is always 'downloadFile.pdf' or 'downloadFile.png'.
How can I retain the original filename? Thanks.