-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Invalid extra_args key 'ChecksumSHA256' for s3_client.upload_file() #3604
Comments
Hi @svbfromnl - thanks for reaching out. |
That sole argument works, but it doesn't do everything I need to. This argument will tell AWS to compute the hash and store it with the object. But the functionality I am looking for is the ability to self-submit a hash along with that argument. According to AWS, it will then compare the self-submitted hash with the hash it computes itself, and reject any uploads if the values don't match. That functionality is implemented by submitting the |
I assume this cannot be used in Only the low-level |
Hey @svbfromnl, We've added support for providing full-object checksums in You should now be able to achieve what you were trying before: import boto3
import io
from boto3.s3.transfer import TransferConfig, MB
TEST_BUCKET = "aws-example-bucket"
TEST_KEY = "aws-example-file.txt"
client = boto3.client("s3")
transfer_config = TransferConfig(
multipart_threshold=8 * MB, # This is the default value, you can change this as needed.
)
response = client.upload_fileobj(
Fileobj=io.BytesIO(b"Hello, World!"),
Bucket=TEST_BUCKET,
Key=TEST_KEY,
Config=transfer_config,
ExtraArgs={
"ChecksumSHA256": "3/1gIbsr1bCvZ2KQgJ7DpTGR3YHH9wpLKGiKNiGCmG8="
}
) One thing I'd warn specifically around SHA algorithms is S3 doesn't support uploading a full-checksum algorithm when doing a MPU. See the related docs below from Checking object integrity in Amazon S3.
High-level operations in boto3 such as As a result, if you attempt to upload a full-object SHA checksum using MPU, you'll receive the following error:
Let me know if you have any questions! |
Describe the bug
I am attempting to
s3_client.upload_file()
a file with a pre-calculated SHA256 hash to make use of the S3 feature that will calculate it's own hash and compare it to what was submitted with the upload.Expected Behavior
I expected the upload to succeed.
Current Behavior
I get the following error:
Invalid extra_args key 'ChecksumSHA256', must be one of: ACL, CacheControl, ChecksumAlgorithm, ContentDisposition, ContentEncoding, ContentLanguage, ContentType, ExpectedBucketOwner, Expires, GrantFullControl, GrantRead, GrantReadACP, GrantWriteACP, Metadata, ObjectLockLegalHoldStatus, ObjectLockMode, ObjectLockRetainUntilDate, RequestPayer, ServerSideEncryption, StorageClass, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, SSEKMSKeyId, SSEKMSEncryptionContext, Tagging, WebsiteRedirectLocation
Reproduction Steps
#python
Possible Solution
Add
ChecksumSHA256
as an allowable argument to be passed through to S3Additional Information/Context
https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html
SDK version used
1.29.63
Environment details (OS name and version, etc.)
macOS Ventura 13.2.1
The text was updated successfully, but these errors were encountered: