I want to create a restful service using spring boot which will download a jar located at the server http:8080/someurl/{fileid}
. How should I do it?
Asked
Active
Viewed 1.4k times
5

Vadim Kotov
- 8,084
- 8
- 48
- 62

Priya
- 253
- 1
- 4
- 12
-
1Have you tried anything so far? If so, please post whatever you have so that the community can help better – EdmDroid Feb 09 '15 at 10:08
-
No. I have just created a service to upload a jar file. Now i want a service to download jar file – Priya Feb 09 '15 at 10:24
-
That's exactly my point. Have you done anything in the direction of making the restful service for downloading the jar? – EdmDroid Feb 09 '15 at 10:26
1 Answers
13
@RequestMapping(value = "/files/{fileID}", method = RequestMethod.GET)
public void getFile(
@PathVariable("fileID") String fileName,
HttpServletResponse response) throws IOException {
String src= DestLocation.concat("\\"+fileName+".jar");
InputStream is = new FileInputStream(src);
IOUtils.copy(is, response.getOutputStream());
response.flushBuffer();
}