Follow up question from my last issue which has since been resolved.
I'm trying to download a file via a Spring @Controller
by returning a FileSystemResource
. I receive a valid HTTP 200 Response and can view all of the file's content in the browser, however I never receive the prompt to download the file. Here's my method:
@RequestMapping(method = RequestMethod.GET, headers="Accept=*/*", value = "/download/{fileName:.+}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@ResponseBody
public FileSystemResource download(@PathVariable String fileName, HttpServletResponse response) throws IOException {
File file = new File(path + '/' + fileName);
response.setContentLength((int)fileName.length());
response.setContentType("application/force-download");
response.setHeader("Content-Disposition","attachment; filename=\"" + fileName + "\"");//fileName);
return new FileSystemResource(file);
}
From the browser:
Response Headers
Content-Disposition | attachment; filename="my_data.CSV"
Content-Length | 1712
Content-Type | text/csv
Request Headers
Accept | */*
Accept-Encoding | gzip, deflate
Accept-Language | en-US,en;q=0.5
Everything appears valid here; any idea why the actual file isn't getting returned? Cheers