Guest User

Untitled

a guest
Aug 7th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1.     @GetMapping("/download/{filename:.+}")
  2.     @ResponseBody
  3.     public ResponseEntity<Resource> downloadFile(@PathVariable String filename) {
  4.  
  5.         Resource resource = storageService.loadAsResource(filename);
  6.  
  7.         return ResponseEntity.ok()
  8.                 .header(HttpHeaders.CONTENT_DISPOSITION,
  9.                         "attachment; filename=\"" + resource.getFilename() + "\"")
  10.                 .body(resource);
  11.     }
Add Comment
Please, Sign In to add comment