Hello i'm trying create an application allowing me host any kind of file. In order to do it i'm exececuting following magic:
@RequestMapping(value = "/files/{file_name}", method = RequestMethod.GET) @ResponseBody public FileSystemResource getFile( @PathVariable("file_name") String fileName) { System.out.println(fileName); String filePath = "./files/"; return new FileSystemResource(new File(filePath+fileName)); } But this approach brings three unwanted problems:
Some random data is beeing appended to the file
The file gets opened in the browser window instead of beeing downloaded - i've tried to hack this using something like
produces = "application/octet-stream"
but it only resulted in 406 error.
The test.txt is beeing truncated into test, i found a walkaround in providing the app with test.txt/ as fileName but it looks a bit messy.