amazon-web-servicesamazon-s3aws-sdkaws-sdk-net

Does AWS S3 allow specifying multiple checksum values (CRC32, CRC32C, SHA1 and SHA256) for one object?


Could there be multiple checksums added (CRC32, CRC32C, SHA1, SHA256 ) all at once, and all of these will be verified?

putObjectRequest.ChecksumSHA256 = "...";
putObjectRequest.ChecksumCRC32 = "...";
putObjectRequest.ChecksumCRC32C = "...";
putObjectRequest.ChecksumSHA1 = "...";

Here I seem can assign only 1 per request

request.ChecksumAlgorithm = ChecksumAlgorithm.SHA256;

Thanks


Solution

  • No, you can't use and/or check multiple additional checksum values.

    You can use Content-MD5 alongside one of these additional checksum algorithms e.g. Content-MD5 +x-amz-checksum-crc32 is fine but Content-MD5 +x-amz-checksum-crc32 + x-amz-checksum-sha1 isn't.

    It's also not a limit of 2 i.e. if you don't send the Content-MD5 header, you can still only use one of the above additional checksums.

    If you try to use more than once e.g. multiple checksums (CRC32, CRC32C, SHA1 and/or SHA256) all at once, the SDKs will throw an error that'll look like this:

    Expecting a single x-amz-checksum- header. Multiple checksum Types are not allowed.

    The .NET SDK specifically will throw an Amazon.S3.AmazonS3Exception with error code of InvalidRequest with the above message.

    The error message is returned by the underlying S3 API.