Created
June 28, 2019 06:41
-
-
Save Webmobsoft/7ee6968d70dbdd2db07a68d5bcad0c2f to your computer and use it in GitHub Desktop.
Download Attachemnt using Name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GetMapping(value = ["downloadFileByName"], produces = [APPLICATION_JSON_VALUE]) | |
fun downloadFileByName(@RequestParam name:String):ResponseEntity<Resource>{ | |
val attachmentIds: List<AttachmentId> = proxy.queryAttachments( | |
AttachmentQueryCriteria.AttachmentsQueryCriteria(filenameCondition = | |
Builder.equal(name)), | |
null | |
) | |
val inputStreams = attachmentIds.map { proxy.openAttachment(it) } | |
val zipToReturn = inputStreams.single() | |
return ResponseEntity.ok().header( | |
HttpHeaders.CONTENT_DISPOSITION, | |
"attachment; filename=\"$name.zip\"" | |
).body(InputStreamResource(zipToReturn)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment