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?
Enter the URL of the REST Service (f.e. http://localhost:8080/rest-file-manager/resr/file/upload ) Select POST as method. Select form-data in the Body. Enter as key “attachment” of Type File.
@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();
}
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