Search in sources :

Example 1 with PresignedAbortMultipartUploadRequest

use of software.amazon.awssdk.services.s3.presigner.model.PresignedAbortMultipartUploadRequest in project aws-sdk-java-v2 by aws.

the class S3PresignerIntegrationTest method abortMultipartUpload_CanBePresigned.

@Test
public void abortMultipartUpload_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())));
    PresignedAbortMultipartUploadRequest presignedRequest = presigner.presignAbortMultipartUpload(r -> r.signatureDuration(Duration.ofDays(1)).abortMultipartUploadRequest(abortMultipartUploadRequest(objectKey, create.uploadId())));
    assertThat(execute(presignedRequest, null).httpResponse().isSuccessful()).isTrue();
    assertThat(getMultipartUpload(objectKey)).isNotPresent();
}
Also used : HttpURLConnection(java.net.HttpURLConnection) BeforeClass(org.junit.BeforeClass) ApacheHttpClient(software.amazon.awssdk.http.apache.ApacheHttpClient) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) CreateMultipartUploadResponse(software.amazon.awssdk.services.s3.model.CreateMultipartUploadResponse) SdkBytes(software.amazon.awssdk.core.SdkBytes) PresignedAbortMultipartUploadRequest(software.amazon.awssdk.services.s3.presigner.model.PresignedAbortMultipartUploadRequest) RequestPayer(software.amazon.awssdk.services.s3.model.RequestPayer) S3Presigner(software.amazon.awssdk.services.s3.presigner.S3Presigner) Duration(java.time.Duration) After(org.junit.After) PresignedPutObjectRequest(software.amazon.awssdk.services.s3.presigner.model.PresignedPutObjectRequest) Before(org.junit.Before) UploadPartRequest(software.amazon.awssdk.services.s3.model.UploadPartRequest) AfterClass(org.junit.AfterClass) MultipartUpload(software.amazon.awssdk.services.s3.model.MultipartUpload) PresignedGetObjectRequest(software.amazon.awssdk.services.s3.presigner.model.PresignedGetObjectRequest) ContentStreamProvider(software.amazon.awssdk.http.ContentStreamProvider) PresignedUploadPartRequest(software.amazon.awssdk.services.s3.presigner.model.PresignedUploadPartRequest) IOException(java.io.IOException) Test(org.junit.Test) PresignedRequest(software.amazon.awssdk.awscore.presigner.PresignedRequest) UUID(java.util.UUID) SdkHttpClient(software.amazon.awssdk.http.SdkHttpClient) CompleteMultipartUploadRequest(software.amazon.awssdk.services.s3.model.CompleteMultipartUploadRequest) PresignedCompleteMultipartUploadRequest(software.amazon.awssdk.services.s3.presigner.model.PresignedCompleteMultipartUploadRequest) S3TestUtils(software.amazon.awssdk.services.s3.utils.S3TestUtils) Consumer(java.util.function.Consumer) AbortableInputStream(software.amazon.awssdk.http.AbortableInputStream) StringInputStream(software.amazon.awssdk.utils.StringInputStream) PresignedCreateMultipartUploadRequest(software.amazon.awssdk.services.s3.presigner.model.PresignedCreateMultipartUploadRequest) Optional(java.util.Optional) RequestBody(software.amazon.awssdk.core.sync.RequestBody) HttpExecuteResponse(software.amazon.awssdk.http.HttpExecuteResponse) CreateMultipartUploadRequest(software.amazon.awssdk.services.s3.model.CreateMultipartUploadRequest) AbortMultipartUploadRequest(software.amazon.awssdk.services.s3.model.AbortMultipartUploadRequest) IoUtils(software.amazon.awssdk.utils.IoUtils) InputStream(java.io.InputStream) HttpExecuteRequest(software.amazon.awssdk.http.HttpExecuteRequest) UploadPartResponse(software.amazon.awssdk.services.s3.model.UploadPartResponse) PresignedAbortMultipartUploadRequest(software.amazon.awssdk.services.s3.presigner.model.PresignedAbortMultipartUploadRequest) CreateMultipartUploadResponse(software.amazon.awssdk.services.s3.model.CreateMultipartUploadResponse) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 Duration (java.time.Duration)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 Consumer (java.util.function.Consumer)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 After (org.junit.After)1 AfterClass (org.junit.AfterClass)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1 PresignedRequest (software.amazon.awssdk.awscore.presigner.PresignedRequest)1 SdkBytes (software.amazon.awssdk.core.SdkBytes)1 RequestBody (software.amazon.awssdk.core.sync.RequestBody)1 AbortableInputStream (software.amazon.awssdk.http.AbortableInputStream)1 ContentStreamProvider (software.amazon.awssdk.http.ContentStreamProvider)1 HttpExecuteRequest (software.amazon.awssdk.http.HttpExecuteRequest)1 HttpExecuteResponse (software.amazon.awssdk.http.HttpExecuteResponse)1