I'm trying to create a put presigned_url with this code:
public URL generatePushResourceLocation(DocumentId documentId, String contentMD5) {
String key = documentId.getId().toString();
PutObjectRequest.Builder putObjectRequestBuilder = PutObjectRequest.builder().bucket(bucket).key(key);
putObjectRequestBuilder.checksumAlgorithm(ChecksumAlgorithm.SHA256);
PutObjectRequest putObjectRequest = putObjectRequestBuilder.build();
PutObjectPresignRequest request = PutObjectPresignRequest.builder().putObjectRequest(putObjectRequest)
.signatureDuration(Duration.ofMinutes(1)).build();
PresignedPutObjectRequest presignPutObject = s3Presigner.presignPutObject(request);
URL signedPutURL = presignPutObject.url();
log.info("Push presigned URL with MD5 content: {}", signedPutURL.toString());
return signedPutURL;
}
The generated url sample is like:
As you can see, a x-amz-sdk-checksum-algorithm parameter is appended.
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?