-
Notifications
You must be signed in to change notification settings - Fork 16
feat: put object with instruction file configured #466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…a into inst-file-put
…a into inst-file-put
…a into inst-file-put
…a into inst-file-put
…r MPU + instructionFile
…tructionFileConfig
…equest to PutObjectRequest
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to include these lines in every file, they should not be deleted here.
"To work around this issue you can disable multi part upload," + | ||
"use the Async client, or not set this value on PutObject." + | ||
"You may be able to update this value after the PutObject request completes." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"To work around this issue you can disable multi part upload," + | |
"use the Async client, or not set this value on PutObject." + | |
"You may be able to update this value after the PutObject request completes." | |
"To work around this issue you can disable Instruction File on PutObject or disable " + | |
"multi part upload, or use the Async client, or not set this value on PutObject." + | |
"You may be able to update this value after the request completes." |
The text should be slightly different as it only applies to cases where InstructionFile puts are enabled.
// Rather than silently dropping the value, | ||
// we loudly signal that we don't know how to handle this field. | ||
throw new IllegalArgumentException( | ||
f.locationName() + " is an unknown field. " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f.locationName() + " is an unknown field. " + | |
f.memberName() + " is an unknown field. " + |
Please fix this in the other convertRequest
method, we missed that originally.
@@ -12,6 +12,131 @@ | |||
|
|||
public class ConvertSDKRequests { | |||
|
|||
public static PutObjectRequest convertRequest(CreateMultipartUploadRequest request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We should add some comments here, i.e. that this is used to set the optional fields for Instruction File puts when the request is a multipart upload, because the instruction file is Put with an ordinary PutObject request.
And likewise for the other convertRequest
method which is used to set the optional fields on high-level Multipart PutObject requests.
@@ -255,6 +262,7 @@ public MultipartUploadObjectPipeline build() { | |||
.secureRandom(_secureRandom) | |||
.build(); | |||
} | |||
_contentMetadataEncodingStrategy = new ContentMetadataEncodingStrategy(_instructionFileConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a null check for instructionFileConfig
, it should never be null but for robustness, we should check if null
and create a default instruction file config.
final InputStream objectStreamForResult = new BoundedInputStream(fileSizeLimit); | ||
|
||
S3Client wrappedClient = S3Client.create(); | ||
S3Client s3Client = S3EncryptionClient.builder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to set .enableMultipartPutObject(true)
to enable multipart put.
.bucket(BUCKET) | ||
.key(object_key + ".instruction") | ||
.build()); | ||
assertTrue(directInstGetResponse.response().metadata().containsKey("x-amz-crypto-instr-file")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also set StorageClass
in the original put request and check for it here.
|
||
|
||
CreateMultipartUploadResponse initiateResult = v3Client.createMultipartUpload(builder -> | ||
builder.bucket(BUCKET).key(object_key)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also set StorageClass
here and check for it in the directInstGetResponse
later on.
@@ -3,6 +3,7 @@ | |||
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; | |||
import software.amazon.awssdk.services.s3.model.*; | |||
|
|||
import java.awt.event.ComponentListener; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks unused
} | ||
|
||
@Test | ||
public void testConversionAllFields() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Specify that this is for CreateMPUToPutObject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor things to fix
/*Converts a CreateMultipartUploadRequest into a PutObjectRequest by setting optional fields needed for | ||
putInstructionFile operation. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a Javadoc comment. Meaning, it comes before the method and it has this syntax (most importantly, the two *
s in the first block):
/**
* Comment here
*/
public whatever methodName() {
There are many examples throughout the codebase. Your IDE should also render them as green rather than grey.
In terms of content, it is not really accurate. We should specify that the conversion is used when Instruction File PutObject is enabled and the customer performs a multipart upload. putInstructionFile
doesn't exist in v3.
@@ -138,7 +140,9 @@ public static PutObjectRequest convertRequest(CreateMultipartUploadRequest reque | |||
} | |||
|
|||
public static CreateMultipartUploadRequest convertRequest(PutObjectRequest request) { | |||
|
|||
/*Converts a PutObjectRequest into a CreateMultipartUploadRequest by setting optional fields needed for high-level |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
@@ -45,6 +45,7 @@ | |||
import software.amazon.awssdk.services.s3.model.PutObjectResponse; | |||
import software.amazon.awssdk.services.s3.model.S3Exception; | |||
import software.amazon.awssdk.services.s3.model.StorageClass; | |||
import software.amazon.awssdk.services.s3.model.StorageClassAnalysisDataExport; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, lets get another review for this though.
Issue #, if available: #355
Description of changes:
*Adds ability to add instruction file configuration for putObject
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Check any applicable: