Skip to content

Instantly share code, notes, and snippets.

@FreeFly19
Created March 21, 2017 08:42
Show Gist options
  • Save FreeFly19/7581963665561d16f5b2baf6728c87cb to your computer and use it in GitHub Desktop.
Save FreeFly19/7581963665561d16f5b2baf6728c87cb to your computer and use it in GitHub Desktop.
Getting file from Controller Spring WEB MVC
@GetMapping(value = "/{documentId}/content")
public ResponseEntity<FileSystemResource> downloadContent(@PathVariable("documentId") Long documentId) {
FileSystemResource fileSystemResource = documentService.getContent(documentId);
return ResponseEntity
.ok()
.contentType(MediaType.valueOf(documentService.getContentType(documentId)))
.body(fileSystemResource);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment