Skip to content

Instantly share code, notes, and snippets.

@Webmobsoft
Created June 28, 2019 06:39
Show Gist options
  • Save Webmobsoft/ad7624a7295ae914194f520e65033183 to your computer and use it in GitHub Desktop.
Save Webmobsoft/ad7624a7295ae914194f520e65033183 to your computer and use it in GitHub Desktop.
Download Using Hash
@GetMapping(value = ["downloadFile/{hash}"], produces = [APPLICATION_JSON_VALUE])
fun downloadFileByHash(@PathVariable hash:String):ResponseEntity<Resource>{
val inputStream = InputStreamResource(proxy.openAttachment(SecureHash.parse(hash)))
return ResponseEntity.ok().header(
HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"$hash.zip\""
).body(inputStream)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment