We are implementing web-app and there is a problem with download file link. The code of controller is:
@RequestMapping(value = "/file" , method = RequestMethod.GET,
produces = "application/jar")
public ResponseEntity<FileSystemResource> getFile() {
FileSystemResource resource = new FileSystemResource(new File(PATH_TO_FILE));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.add("Content-Disposition", "attachment; filename=" + FILE_NAME);
responseHeaders.add("Content-Type", "application/jar");
ResponseEntity<FileSystemResource> responseEntity = new ResponseEntity<>(resource, responseHeaders, HttpStatus.OK);
return responseEntity;
}
Problem is that it downloads well from browser, but not, for instance, from wget.
when I try to make
wget localhost:8080/file
I download it but not as file.jar (which is FILE_NAME), but just a file without extension.
Is there any solutions?
UPD: I've also tried to change request to file.jar. But by some reason this request didnt shoot. Also I tried to make a regexp (i dont remember well, something like this)
{filename:[a-zA-Z0-9]+}{extension:\\.[a-z]+}
But it only cought requests like aaa.bbb, fsdf.sdkfjsdkf (I mean some random), but not a file.jar. Seems like there is special request handlers in Spring Boot?
Nevertheless, how to solve such problem?
Thank you
Aucun commentaire:
Enregistrer un commentaire