use of com.adeptj.modules.aws.s3.S3Response in project adeptj-modules by AdeptJ.
the class AwsS3Service method createFolder.
/**
* {@inheritDoc}
*/
@Override
public S3Response createFolder(String bucketName, String folderName) {
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentLength(0);
try {
return new S3Response().withPutObjectResult(this.s3Client.putObject(new PutObjectRequest(bucketName, folderName + PATH_SEPARATOR, new ByteArrayInputStream(new byte[0]), objectMetadata)));
} catch (RuntimeException ex) {
LOGGER.error("Exception while creating folder!!", ex);
throw new AwsException(ex.getMessage(), ex);
}
}
use of com.adeptj.modules.aws.s3.S3Response in project adeptj-modules by AdeptJ.
the class AwsS3Service method uploadFile.
/**
* {@inheritDoc}
*/
@Override
public S3Response uploadFile(S3Request request) {
ObjectMetadata objectMetadata = Objects.requireNonNull(request.getMetadata(), OBJ_METADATA_NULL_MSG);
CannedAccessControlList cannedACL = Objects.requireNonNull(request.getCannedACL(), ACL_NULL_MSG);
try (InputStream data = Objects.requireNonNull(request.getData(), DATA_NULL_MSG)) {
return new S3Response().withPutObjectResult(this.s3Client.putObject(new PutObjectRequest(request.getBucketName(), request.getKey(), data, objectMetadata).withCannedAcl(cannedACL)));
} catch (Exception ex) {
LOGGER.error("Exception while uploading file!!", ex);
throw new AwsException(ex.getMessage(), ex);
}
}
Aggregations