|
20 | 20 | import software.amazon.awssdk.services.s3.model.SdkPartType; |
21 | 21 | import software.amazon.awssdk.services.s3.model.UploadPartRequest; |
22 | 22 | import software.amazon.awssdk.services.s3.model.UploadPartResponse; |
| 23 | +import software.amazon.awssdk.services.s3.model.StorageClass; |
23 | 24 | import software.amazon.awssdk.utils.IoUtils; |
24 | 25 | import software.amazon.encryption.s3.utils.BoundedInputStream; |
25 | 26 |
|
@@ -522,4 +523,43 @@ public void multipartUploadV3OutputStreamPartSizeMismatch() throws IOException { |
522 | 523 | v3Client.close(); |
523 | 524 | } |
524 | 525 |
|
| 526 | + @Test |
| 527 | + public void multipartPutObjectWithOptions() throws IOException { |
| 528 | + final String objectKey = appendTestSuffix("multipart-put-object-with-options"); |
| 529 | + |
| 530 | + final long fileSizeLimit = 1024 * 1024 * 10; |
| 531 | + final InputStream inputStream = new BoundedInputStream(fileSizeLimit); |
| 532 | + final InputStream objectStreamForResult = new BoundedInputStream(fileSizeLimit); |
| 533 | + |
| 534 | + final S3Client v3Client = S3EncryptionClient.builder() |
| 535 | + .kmsKeyId(KMS_KEY_ID) |
| 536 | + .enableMultipartPutObject(true) |
| 537 | + .enableDelayedAuthenticationMode(true) |
| 538 | + .cryptoProvider(PROVIDER) |
| 539 | + .build(); |
| 540 | + |
| 541 | + final Map<String, String> encryptionContext = new HashMap<>(); |
| 542 | + encryptionContext.put("user-metadata-key", "user-metadata-value-v3-to-v3"); |
| 543 | + |
| 544 | + final StorageClass storageClass = StorageClass.INTELLIGENT_TIERING; |
| 545 | + |
| 546 | + v3Client.putObject(builder -> builder |
| 547 | + .bucket(BUCKET) |
| 548 | + .overrideConfiguration(withAdditionalConfiguration(encryptionContext)) |
| 549 | + .storageClass(storageClass) |
| 550 | + .key(objectKey), RequestBody.fromInputStream(inputStream, fileSizeLimit)); |
| 551 | + |
| 552 | + // Asserts |
| 553 | + final ResponseInputStream<GetObjectResponse> output = v3Client.getObject(builder -> builder |
| 554 | + .bucket(BUCKET) |
| 555 | + .overrideConfiguration(S3EncryptionClient.withAdditionalConfiguration(encryptionContext)) |
| 556 | + .key(objectKey)); |
| 557 | + |
| 558 | + assertTrue(IOUtils.contentEquals(objectStreamForResult, output)); |
| 559 | + assertEquals(storageClass, output.response().storageClass()); |
| 560 | + |
| 561 | + v3Client.deleteObject(builder -> builder.bucket(BUCKET).key(objectKey)); |
| 562 | + v3Client.close(); |
| 563 | + } |
| 564 | + |
525 | 565 | } |
0 commit comments