Below code is always downloading a f.txt
file rather downloading without the actual file name and extension(here .zip extension).
@RequestMapping(value = "/files/{fileId}", method = RequestMethod.GET, produces = "application/zip")
public ResponseEntity<Resource> downloadFile(@PathVariable("fileId") String fileName) {
log.info("Downloading file..!!!!");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.valueOf("application/zip"));
log.info("Content info : "+headers.getContentType().toString());
File file = FileUtils.getFile("backup/" + fileName + ".zip");
log.info("File name is : "+file.getName());
FileSystemResource fileSystemResource = new FileSystemResource(file);
return new ResponseEntity<>(fileSystemResource, headers, HttpStatus.OK);
}
It would be great if someone can let me know where the mistake is/ some amendments to be done?
f.txt
is coming from the Content-Disposition
response header. This is a consequence of fixing cve-2015-5211 (RFD Attack)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With