/** * ************************************************* URL: /rest/controller/get/{value} get(): get * file as an attachment * * @param response : passed by the server * @param value : value from the URL * @return void ************************************************** */ @RequestMapping(value = "/get/{value}", method = RequestMethod.GET) public void get(HttpServletResponse response, @PathVariable String value) { FileMeta getFile = files.get(Integer.parseInt(value)); try { response.setContentType(getFile.getFileType()); response.setHeader( "Content-disposition", "attachment; filename=\"" + getFile.getFileName() + "\""); FileCopyUtils.copy(getFile.getBytes(), response.getOutputStream()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }