@Override public PutObjectRequest decorate(PutObjectRequest request) { final ObjectMetadata objectMetadata = request.getMetadata() == null ? new ObjectMetadata() : request.getMetadata().clone(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); return request.withMetadata(objectMetadata); }
@Override public CopyObjectRequest decorate(CopyObjectRequest request) { final ObjectMetadata objectMetadata = request.getNewObjectMetadata() == null ? new ObjectMetadata() : request.getNewObjectMetadata().clone(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); return request.withNewObjectMetadata(objectMetadata); } }
/** * Returns a clone (as deep as possible) of this request object. */ @Override public UploadObjectRequest clone() { final UploadObjectRequest cloned = (UploadObjectRequest) super.clone(); super.copyPutObjectBaseTo(cloned); final Map<String, String> materialsDescription = getMaterialsDescription(); final ObjectMetadata uploadPartMetadata = getUploadPartMetadata(); return cloned .withMaterialsDescription(materialsDescription == null ? null : new HashMap<String, String>(materialsDescription)) .withDiskLimit(getDiskLimit()) .withExecutorService(getExecutorService()) .withMultiFileOutputStream(getMultiFileOutputStream()) .withPartSize(getPartSize()) .withUploadObjectObserver(getUploadObjectObserver()) .withUploadPartMetadata(uploadPartMetadata == null ? null : uploadPartMetadata.clone()) ; } }
protected final <T extends AbstractPutObjectRequest> T copyPutObjectBaseTo( T target) { copyBaseTo(target); final ObjectMetadata metadata = getMetadata(); return target.withAccessControlList(getAccessControlList()) .withCannedAcl(getCannedAcl()) .withInputStream(getInputStream()) .withMetadata(metadata == null ? null : metadata.clone()) .withRedirectLocation(getRedirectLocation()) .withStorageClass(getStorageClass()) .withSSEAwsKeyManagementParams(getSSEAwsKeyManagementParams()) .withSSECustomerKey(getSSECustomerKey()) ; } }
/** * Returns a clone (as deep as possible) of this request object. * * @throws CloneNotSupportedException */ @Override public UploadObjectRequest clone() { final UploadObjectRequest cloned = (UploadObjectRequest) super.clone(); super.copyPutObjectBaseTo(cloned); final Map<String, String> materialsDescription = getMaterialsDescription(); final ObjectMetadata uploadPartMetadata = getUploadPartMetadata(); return cloned .withMaterialsDescription(materialsDescription == null ? null : new HashMap<String, String>(materialsDescription)) .withDiskLimit(getDiskLimit()) .withExecutorService(getExecutorService()) .withPartSize(getPartSize()) .withUploadObjectObserver(getUploadObjectObserver()) .withUploadPartMetadata(uploadPartMetadata == null ? null : uploadPartMetadata.clone()) ; } }
protected final <T extends AbstractPutObjectRequest> T copyPutObjectBaseTo( T target) { copyBaseTo(target); final ObjectMetadata metadata = getMetadata(); return target.withAccessControlList(getAccessControlList()) .withCannedAcl(getCannedAcl()) .withInputStream(getInputStream()) .withMetadata(metadata == null ? null : metadata.clone()) .withRedirectLocation(getRedirectLocation()) .withStorageClass(getStorageClass()) .withSSEAwsKeyManagementParams(getSSEAwsKeyManagementParams()) .withSSECustomerKey(getSSECustomerKey()); } }
public static boolean putObject(AmazonS3 s3, String bucketName, String objectKey, byte[] content, ObjectMetadata metadata) { if ((content != null) && (content.length > 0)) { try(InputStream contentInputStream = new ByteArrayInputStream(content)) { ObjectMetadata objectMetadata = metadata.clone(); objectMetadata.setContentLength(content.length); s3.putObject(bucketName, objectKey, contentInputStream, objectMetadata); return true; } catch (IOException e) { return false; } } return false; }
@Override public PutObjectRequest decorate(PutObjectRequest request) { final ObjectMetadata objectMetadata = request.getMetadata() == null ? new ObjectMetadata() : request.getMetadata().clone(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); return request.withMetadata(objectMetadata); }
@Override public CopyObjectRequest decorate(CopyObjectRequest request) { final ObjectMetadata objectMetadata = request.getNewObjectMetadata() == null ? new ObjectMetadata() : request.getNewObjectMetadata().clone(); objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); return request.withNewObjectMetadata(objectMetadata); } }
@Test public void cloneEmpty() { ObjectMetadata from = new ObjectMetadata(); for (int i = 0; i < 2; i++) { assertNull(from.getCacheControl()); assertNull(from.getContentDisposition()); assertNull(from.getContentEncoding()); assertTrue(0 == from.getContentLength()); assertNull(from.getContentMD5()); assertNull(from.getContentType()); assertNull(from.getETag()); assertNull(from.getExpirationTime()); assertNull(from.getExpirationTimeRuleId()); assertNull(from.getHttpExpiresDate()); assertTrue(0 == from.getInstanceLength()); assertNull(from.getLastModified()); assertNull(from.getOngoingRestore()); assertTrue(from.getRawMetadata().size() == 0); assertNull(from.getRestoreExpirationTime()); assertNull(from.getSSEAlgorithm()); assertNull(from.getSSECustomerAlgorithm()); assertNull(from.getSSECustomerKeyMd5()); assertTrue(0 == from.getUserMetadata().size()); assertNull(from.getVersionId()); assertNull(from.getStorageClass()); // Clone an empty instance from = from.clone(); } }
final ObjectMetadata dstom = srcom.clone(); if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) { dstom.setServerSideEncryption(serverSideEncryptionAlgorithm);
ObjectMetadata to = from.clone(); assertEquals("cachecontrol", to.getCacheControl()); assertEquals("contentDisposition", to.getContentDisposition());
final ObjectMetadata dstom = srcom.clone(); if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) { dstom.setServerSideEncryption(serverSideEncryptionAlgorithm);
/** * Returns a clone (as deep as possible) of this request object. * * @throws CloneNotSupportedException */ @Override public UploadObjectRequest clone() { final UploadObjectRequest cloned = (UploadObjectRequest) super.clone(); super.copyPutObjectBaseTo(cloned); final Map<String, String> materialsDescription = getMaterialsDescription(); final ObjectMetadata uploadPartMetadata = getUploadPartMetadata(); return cloned .withMaterialsDescription(materialsDescription == null ? null : new HashMap<String, String>(materialsDescription)) .withDiskLimit(getDiskLimit()) .withExecutorService(getExecutorService()) .withPartSize(getPartSize()) .withUploadObjectObserver(getUploadObjectObserver()) .withUploadPartMetadata(uploadPartMetadata == null ? null : uploadPartMetadata.clone()) ; } }
/** * Returns a clone (as deep as possible) of this request object. */ @Override public UploadObjectRequest clone() { final UploadObjectRequest cloned = (UploadObjectRequest) super.clone(); super.copyPutObjectBaseTo(cloned); final Map<String, String> materialsDescription = getMaterialsDescription(); final ObjectMetadata uploadPartMetadata = getUploadPartMetadata(); return cloned .withMaterialsDescription(materialsDescription == null ? null : new HashMap<String, String>(materialsDescription)) .withDiskLimit(getDiskLimit()) .withExecutorService(getExecutorService()) .withMultiFileOutputStream(getMultiFileOutputStream()) .withPartSize(getPartSize()) .withUploadObjectObserver(getUploadObjectObserver()) .withUploadPartMetadata(uploadPartMetadata == null ? null : uploadPartMetadata.clone()) ; } }
protected final <T extends AbstractPutObjectRequest> T copyPutObjectBaseTo( T target) { copyBaseTo(target); final ObjectMetadata metadata = getMetadata(); return target.withAccessControlList(getAccessControlList()) .withCannedAcl(getCannedAcl()) .withInputStream(getInputStream()) .withMetadata(metadata == null ? null : metadata.clone()) .withRedirectLocation(getRedirectLocation()) .withStorageClass(getStorageClass()) .withSSEAwsKeyManagementParams(getSSEAwsKeyManagementParams()) .withSSECustomerKey(getSSECustomerKey()); } }
protected final <T extends AbstractPutObjectRequest> T copyPutObjectBaseTo( T target) { copyBaseTo(target); final ObjectMetadata metadata = getMetadata(); return target.withAccessControlList(getAccessControlList()) .withCannedAcl(getCannedAcl()) .withInputStream(getInputStream()) .withMetadata(metadata == null ? null : metadata.clone()) .withRedirectLocation(getRedirectLocation()) .withStorageClass(getStorageClass()) .withSSEAwsKeyManagementParams(getSSEAwsKeyManagementParams()) .withSSECustomerKey(getSSECustomerKey()) ; } }