Description
Type: Bug
Component:
"S3"
Describe the bug
I'm trying to create PUT
presigned url` in order to send them to the client and client makes the upload to my S3 bucket.
My S3 is configured to send PutObejct
events to an SQS
. Then, I need to get the checksum of uploaded file in order to store the checksum into my database.
I'm trying to create a put presigned_url
with this code:
public URL generatePushResourceLocation(DocumentId documentId, String contentMD5) {
ObjectMetadata objectMetadata = ObjectMetadata.builder().checksumAlgorithm(ChecksumAlgorithm.SHA256).build();
URL signedPutURL = s3Template.createSignedPutURL(this.bucket, key, Duration.ofMinutes(10), objectMetadata, null);
return signedPutURL;
}
The generated url sample is like:
As you can see, a x-amz-sdk-checksum-algorithm
parameter is appended, but it's empty.
When I make the PUT using generated presigned url
everything seems to work, but when I'm trying to get object attributes, I'm not getting any ChecksumSHA256
:
$ aws s3api get-object-attributes --bucket $BUCKET_NAME --key $KEY --object-attributes "ObjectSize" "Checksum" | yq .
{
"LastModified": "2024-03-08T12:05:24+00:00",
"ObjectSize": 2333
}
I'm trying to simulate this behavior using cli
:
$ aws s3api put-object --bucket $BUCKET_NAME --key $KEY --body pom.xml --checksum-algorithm SHA256 | yq .
{
"ETag": "\"44a7a97ddff52b27557a39cb2983ae62\"",
"ChecksumSHA256": "ZR6CNpjrGvQWPPkaHiAeTWm2La1ZZIHLjtrFaPjnaPc=",
"ServerSideEncryption": "AES256"
}
Also, I'm able to get object attributes like:
$ aws s3api get-object-attributes --bucket $BUCKET_NAME --key $KEY --object-attributes "ObjectSize" "Checksum" | yq .
{
"LastModified": "2024-03-08T12:01:16+00:00",
"Checksum": {
"ChecksumSHA256": "ZR6CNpjrGvQWPPkaHiAeTWm2La1ZZIHLjtrFaPjnaPc="
},
"ObjectSize": 2097
}
Isn't it able to set a checksum algorithm on presigned PUT url?