use of software.amazon.awssdk.services.s3.model.RequestPayer in project aws-sdk-java-v2 by aws.
the class S3PresignerIntegrationTest method browserIncompatiblePresignedUrlWorksWithAdditionalHeaders.
@Test
public void browserIncompatiblePresignedUrlWorksWithAdditionalHeaders() throws IOException {
PresignedGetObjectRequest presigned = presigner.presignGetObject(r -> r.signatureDuration(Duration.ofMinutes(5)).getObjectRequest(gor -> gor.bucket(testBucket).key(testGetObjectKey).requestPayer(RequestPayer.REQUESTER)));
assertThat(presigned.isBrowserExecutable()).isFalse();
HttpURLConnection connection = (HttpURLConnection) presigned.url().openConnection();
presigned.httpRequest().headers().forEach((header, values) -> {
values.forEach(value -> {
connection.addRequestProperty(header, value);
});
});
try (InputStream content = connection.getInputStream()) {
assertThat(IoUtils.toUtf8String(content)).isEqualTo(testObjectContent);
}
}
use of software.amazon.awssdk.services.s3.model.RequestPayer in project hedera-mirror-node by hashgraph.
the class Downloader method listFiles.
private List<S3Object> listFiles(String lastFilename, String nodeAccountId) throws ExecutionException, InterruptedException {
// batchSize (number of items we plan do download in a single batch) times 2 for file + sig.
int listSize = (downloaderProperties.getBatchSize() * 2);
String s3Prefix = getS3Prefix(nodeAccountId);
// Not using ListObjectsV2Request because it does not work with GCP.
ListObjectsRequest listRequest = ListObjectsRequest.builder().bucket(commonDownloaderProperties.getBucketName()).prefix(s3Prefix).delimiter("/").marker(s3Prefix + lastFilename).maxKeys(listSize).requestPayer(RequestPayer.REQUESTER).build();
return s3Client.listObjects(listRequest).get().contents();
}
use of software.amazon.awssdk.services.s3.model.RequestPayer in project spring-cloud-aws by awspring.
the class ObjectMetadataTests method mapsEnumsToString.
@Test
void mapsEnumsToString() {
ObjectMetadata metadata = ObjectMetadata.builder().acl(ObjectCannedACL.AUTHENTICATED_READ).storageClass(StorageClass.ONEZONE_IA).objectLockLegalHoldStatus(ObjectLockLegalHoldStatus.OFF).requestPayer(RequestPayer.REQUESTER).serverSideEncryption(ServerSideEncryption.AES256).checksumAlgorithm(ChecksumAlgorithm.CRC32).build();
PutObjectRequest.Builder builder = PutObjectRequest.builder();
metadata.apply(builder);
PutObjectRequest result = builder.build();
assertThat(result.acl()).isEqualTo(ObjectCannedACL.AUTHENTICATED_READ);
assertThat(result.storageClass()).isEqualTo(StorageClass.ONEZONE_IA);
assertThat(result.objectLockLegalHoldStatus()).isEqualTo(ObjectLockLegalHoldStatus.OFF);
assertThat(result.requestPayer()).isEqualTo(RequestPayer.REQUESTER);
assertThat(result.serverSideEncryption()).isEqualTo(ServerSideEncryption.AES256);
assertThat(result.checksumAlgorithm()).isEqualTo(ChecksumAlgorithm.CRC32);
}
use of software.amazon.awssdk.services.s3.model.RequestPayer in project spring-cloud-aws by awspring.
the class ObjectMetadataTests method canBeAppliedToPutObjectRequest.
@Test
void canBeAppliedToPutObjectRequest() {
Instant now = Instant.now();
ObjectMetadata objectMetadata = ObjectMetadata.builder().acl("acl").cacheControl("cacheControl").contentDisposition("contentDisposition").contentEncoding("contentEncoding").contentLanguage("contentLanguage").contentType("contentType").expires(now).grantFullControl("grantFullControl").grantRead("grantRead").grantReadACP("grantReadACP").grantWriteACP("grantWriteACP").metadata("key1", "value1").metadata("key2", "value2").serverSideEncryption("serverSideEncryption").storageClass("storageClass").websiteRedirectLocation("websiteRedirectLocation").sseCustomerAlgorithm("sseCustomerAlgorithm").sseCustomerKey("sseCustomerKey").sseCustomerKeyMD5("sseCustomerKeyMD5").ssekmsKeyId("ssekmsKeyId").ssekmsEncryptionContext("ssekmsEncryptionContext").bucketKeyEnabled(true).requestPayer("requestPayer").tagging("tagging").objectLockMode("objectLockMode").objectLockRetainUntilDate(now).objectLockLegalHoldStatus("objectLockLegalHoldStatus").expectedBucketOwner("expectedBucketOwner").checksumAlgorithm("checksumAlgorithm").build();
PutObjectRequest.Builder builder = PutObjectRequest.builder();
objectMetadata.apply(builder);
assertThat(builder).usingRecursiveComparison().ignoringFields("awsRequestOverrideConfig", "checksumCRC32C", "checksumSHA1", "checksumSHA256", "key", "contentMD5", "bucket", "checksumCRC32", "contentLength").isEqualTo(objectMetadata);
}
use of software.amazon.awssdk.services.s3.model.RequestPayer in project aws-sdk-java-v2 by aws.
the class S3PresignerIntegrationTest method browserIncompatiblePresignedUrlDoesNotWorkWithoutAdditionalHeaders.
@Test
public void browserIncompatiblePresignedUrlDoesNotWorkWithoutAdditionalHeaders() throws IOException {
PresignedGetObjectRequest presigned = presigner.presignGetObject(r -> r.signatureDuration(Duration.ofMinutes(5)).getObjectRequest(gor -> gor.bucket(testBucket).key(testGetObjectKey).requestPayer(RequestPayer.REQUESTER)));
assertThat(presigned.isBrowserExecutable()).isFalse();
HttpURLConnection connection = (HttpURLConnection) presigned.url().openConnection();
connection.connect();
try {
assertThat(connection.getResponseCode()).isEqualTo(403);
} finally {
connection.disconnect();
}
}
Aggregations