Spring boot file to download file

I want to create a sedative service using spring download, which will load the jar located on the server http:8080/someurl/{fileid} . How can I do it?

+5
source share
1 answer
  @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(); } 
+13
source

Source: https://habr.com/ru/post/1212951/


All Articles