/** * Same as {@link #setObjectAcl(String, String, String, AccessControlList)} * but allows specifying a request metric collector. */ public void setObjectAcl(String bucketName, String key, String versionId, AccessControlList acl, RequestMetricCollector requestMetricCollector) throws SdkClientException, AmazonServiceException { setObjectAcl(new SetObjectAclRequest(bucketName, key, versionId, acl) .<SetObjectAclRequest> withRequestMetricCollector(requestMetricCollector)); }
/** * Same as {@link #setObjectAcl(String, String, String, CannedAccessControlList)} * but allows specifying a request metric collector. */ public void setObjectAcl(String bucketName, String key, String versionId, CannedAccessControlList acl, RequestMetricCollector requestMetricCollector) { setObjectAcl(new SetObjectAclRequest(bucketName, key, versionId, acl) .<SetObjectAclRequest> withRequestMetricCollector(requestMetricCollector)); }
@Override public void setObjectAcl(SetObjectAclRequest setObjectAclRequest) throws SdkClientException, AmazonServiceException { setObjectAclRequest = beforeClientExecution(setObjectAclRequest); rejectNull(setObjectAclRequest, "The request must not be null."); rejectNull(setObjectAclRequest.getBucketName(), "The bucket name parameter must be specified when setting an object's ACL"); rejectNull(setObjectAclRequest.getKey(), "The key parameter must be specified when setting an object's ACL"); if (setObjectAclRequest.getAcl() != null && setObjectAclRequest.getCannedAcl() != null) { throw new IllegalArgumentException( "Only one of the ACL and CannedACL parameters can be specified, not both."); } if (setObjectAclRequest.getAcl() != null) { setAcl(setObjectAclRequest.getBucketName(), setObjectAclRequest.getKey(), setObjectAclRequest.getVersionId(), setObjectAclRequest.getAcl(), setObjectAclRequest.isRequesterPays(), setObjectAclRequest); } else if (setObjectAclRequest.getCannedAcl() != null) { setAcl(setObjectAclRequest.getBucketName(), setObjectAclRequest.getKey(), setObjectAclRequest.getVersionId(), setObjectAclRequest.getCannedAcl(), setObjectAclRequest.isRequesterPays(), setObjectAclRequest); } else { throw new IllegalArgumentException( "At least one of the ACL and CannedACL parameters should be specified"); } }
@Override public void setObjectAcl(SetObjectAclRequest setObjectAclRequest) throws AmazonClientException, AmazonServiceException { delegate.setObjectAcl(setObjectAclRequest); }
@Override public void setObjectAcl(String bucketName, String key, String versionId, AccessControlList acl) throws SdkClientException, AmazonServiceException { setObjectAcl(new SetObjectAclRequest(bucketName, key, versionId, acl)); }
@Override public void setObjectAcl(String bucketName, String key, String versionId, CannedAccessControlList acl) throws SdkClientException, AmazonServiceException { setObjectAcl(new SetObjectAclRequest(bucketName, key, versionId, acl)); }
@Override public void setObjectAcl(SetObjectAclRequest setObjectAclRequest) throws SdkClientException, AmazonServiceException { run(() -> getDelegate().setObjectAcl(setObjectAclRequest)); }
@Test @Override public void test() throws Exception { AmazonS3 amazonS3Client = TestUtils.getPropertyValue(this.s3MessageHandler, "transferManager.s3", AmazonS3.class); File file = this.temporaryFolder.newFile("foo.mp3"); Message<?> message = MessageBuilder.withPayload(file) .build(); this.channels.input().send(message); ArgumentCaptor<PutObjectRequest> putObjectRequestArgumentCaptor = ArgumentCaptor.forClass(PutObjectRequest.class); verify(amazonS3Client, atLeastOnce()).putObject(putObjectRequestArgumentCaptor.capture()); PutObjectRequest putObjectRequest = putObjectRequestArgumentCaptor.getValue(); assertThat(putObjectRequest.getBucketName(), equalTo(S3_BUCKET)); assertThat(putObjectRequest.getKey(), equalTo("foo.mp3")); assertNotNull(putObjectRequest.getFile()); assertNull(putObjectRequest.getInputStream()); ObjectMetadata metadata = putObjectRequest.getMetadata(); assertThat(metadata.getContentMD5(), equalTo(Md5Utils.md5AsBase64(file))); assertThat(metadata.getContentLength(), equalTo(0L)); assertThat(metadata.getContentType(), equalTo("audio/mpeg")); ProgressListener listener = putObjectRequest.getGeneralProgressListener(); S3ProgressPublisher.publishProgress(listener, ProgressEventType.TRANSFER_COMPLETED_EVENT); assertTrue(this.transferCompletedLatch.await(10, TimeUnit.SECONDS)); assertTrue(this.aclLatch.await(10, TimeUnit.SECONDS)); ArgumentCaptor<SetObjectAclRequest> setObjectAclRequestArgumentCaptor = ArgumentCaptor.forClass(SetObjectAclRequest.class); verify(amazonS3Client).setObjectAcl(setObjectAclRequestArgumentCaptor.capture()); SetObjectAclRequest setObjectAclRequest = setObjectAclRequestArgumentCaptor.getValue(); assertThat(setObjectAclRequest.getBucketName(), equalTo(S3_BUCKET)); assertThat(setObjectAclRequest.getKey(), equalTo("foo.mp3")); assertNull(setObjectAclRequest.getAcl()); assertThat(setObjectAclRequest.getCannedAcl(), equalTo(CannedAccessControlList.PublicReadWrite)); }
@Override public void setObjectAcl(SetObjectAclRequest setObjectAclRequest) throws AmazonClientException { }