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
@PostMapping(value = ["uploadFile"], produces =[APPLICATION_JSON_VALUE]) | |
fun uploadFile(@RequestParam file: MultipartFile, @RequestParam uploader: String):ResponseEntity<String>{ | |
val filename = file.originalFilename | |
val uploader = uploader | |
require(filename != null) {"File Name must be set"} | |
val hash: SecureHash = if(!(file.contentType == "zip" || file.contentType == "jar")){ | |
uploadZip(file.inputStream, uploader,filename!!) | |
}else{ | |
proxy.uploadAttachmentWithMetadata( | |
jar = file.inputStream, |
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 = ["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) | |
} |
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( |
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
@PostMapping(value = ["uploadFile"], produces =[APPLICATION_JSON_VALUE]) | |
fun uploadFile(@RequestParam file: MultipartFile, @RequestParam uploadBy: String):ResponseEntity<String>{ | |
val filename = file.originalFilename | |
val uploadBy = uploadBy | |
require(filename != null) {"File Must be Selected"} | |
val hash: SecureHash = if(!(file.contentType == "zip")){ | |
upload(file.inputStream, uploadBy,filename!!) | |
}else{ | |
proxy.uploadAttachmentWithMetadata( | |
jar = file.inputStream, |