我希望使用Spring Boot创建一个RESTful服务,该服务将从位于服务器上的URL http:8080/someurl/{fileid}
下载一个JAR文件。该如何实现呢?
我希望使用Spring Boot创建一个RESTful服务,该服务将从位于服务器上的URL http:8080/someurl/{fileid}
下载一个JAR文件。该如何实现呢?
@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();
}