use of com.adeptj.modules.jaxrs.core.jwt.RequiresJwt in project adeptj-modules by AdeptJ.
the class UploadResource method uploadFile.
@POST
@Path(PATH_UPLOAD)
@Consumes(MULTIPART_FORM_DATA)
@RequiresJwt
public Response uploadFile(@MultipartForm FileUploadForm form) {
try {
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength((long) form.getData().length);
this.storageService.uploadFile(S3Request.builder().bucketName(form.getBucketName()).key(form.getKey()).data(IOUtils.buffer(new ByteArrayInputStream(form.getData()))).metadata(metadata).cannedACL(CannedAccessControlList.valueOf(form.getAccess())).build());
return Response.ok("File uploaded successfully!!").build();
} catch (Exception ex) {
// NOSONAR
throw JaxRSException.builder().message(ex.getMessage()).cause(ex).status(STATUS_SERVER_ERROR).logException(true).build();
}
}
Aggregations