AWS S3api put-object: unknown options (checksum-crc32)

Viewed 251

So I want to upload a file and have AWS perform a specified CRC32 (let's say the CRC is ABCD1234) check after the upload, but i keep getting this error.

usage: aws [options] [ ...] [parameters] To see help text, you can run:

aws help aws help aws help

Unknown options: --checksumcrc32, ABCD1234

The command I use goes as follows (brackets [] for variables)

aws s3api put-object --bucket [BUCKET_NAME] --checksum-crc32 "ABCD1234" --key [NAME_OF_FILE] --body [DESTINATION_PATH] --profile [PROFILE_NAME]

Uploads without the --checksum-crc32 work just fine.

Version: aws-cli/2.4.4

Any guesses why I get this error?

Thanks in advance!

2 Answers

The documentation says that the CRC needs to be Base-64 encoded, not hexadecimal:

--checksum-crc32 (string)

This header can be used as a data integrity check to verify that the data received is the same data that was originally sent. This header specifies the base64-encoded, 32-bit CRC32 checksum of the object. For more information, see Checking object integrity in the Amazon S3 User Guide .

So your ABCD1234 would need to be either q80SNA== or NBLNqw==, depending on whether they expect the 32 bits to be rendered in big-endian or little-endian order, respectively. I didn't see anything in the documentation that says which it is.

The CRC32 doesn't match their calculation. Make sure you're encoding it properly.

You don't need to specify the checksum on the cli, you can have the client calculate it by removing --checksum-crc32 and replacing it with --checksum-algorithm "crc32"

If your goal is data integrity, consider a cryptographically secure algorithm like SHA256, which can also be automatically calculated by the cli.

Related