use of software.amazon.awssdk.services.s3.presigner.model.PresignedCompleteMultipartUploadRequest in project aws-sdk-java-v2 by aws.
the class S3PresignerIntegrationTest method completeMultipartUpload_CanBePresigned.
@Test
public void completeMultipartUpload_CanBePresigned() throws IOException {
String objectKey = generateRandomObjectKey();
S3TestUtils.addCleanupTask(S3PresignerIntegrationTest.class, () -> client.deleteObject(r -> r.bucket(testBucket).key(objectKey)));
CreateMultipartUploadResponse create = client.createMultipartUpload(createMultipartUploadRequest(objectKey));
S3TestUtils.addCleanupTask(S3PresignerIntegrationTest.class, () -> client.abortMultipartUpload(abortMultipartUploadRequest(objectKey, create.uploadId())));
UploadPartResponse uploadPartResponse = client.uploadPart(uploadPartRequest(objectKey, create), RequestBody.fromString(testObjectContent));
String etag = uploadPartResponse.eTag();
PresignedCompleteMultipartUploadRequest presignedRequest = presigner.presignCompleteMultipartUpload(r -> r.signatureDuration(Duration.ofDays(1)).completeMultipartUploadRequest(createMultipartUploadRequest(objectKey, create, etag)));
assertThat(execute(presignedRequest, presignedRequest.signedPayload().get().asUtf8String()).httpResponse().isSuccessful()).isTrue();
String content = client.getObjectAsBytes(r -> r.bucket(testBucket).key(objectKey)).asUtf8String();
assertThat(content).isEqualTo(testObjectContent);
}
Aggregations