Bad digest when `PutObject` in R2 with `x-amz-content-sha256`

For Workers & Pages, what is the name of the domain?

ultstack.com

What is the error number?

400

What is the error message?

The SHA-256 checksum you specified did not match what we received. You provided a SHA-256 checksum with value: ba0ae0f180f859d2cbcfd8802b5a262bf09cc400a7a752768375072c250b1092. Actual SHA-256 was: ba0ae0f180f859d2cbcfd8802b5a262bf09cc7e0a7a752768375072c250b1092

What is the issue or error you’re encountering

The checksum is valid (even in the error message), but R2 rejects it

What are the steps to reproduce the issue?

Upload a file with correct checksum.

May I ask if you’re using AWS CLI, or rather AWS SDK for some language such as PHP? If so, which version? :thinking:

Other that PutObject, does the connecton and listing the bucket work fine with the token and secret?

I’m using JavaScript SDK version 3.726.1, and other bucket operation doesn’t have any problem. If I don’t provide SHA256 checksum, the PutObject command also succeeded.

My guess would be leading or trailing space. Check that the hash you’re giving is exact

1 Like

Nope. The error message showed that the checksum are the same. Besides, the checksum should be in base64-encoded format, not the hex one. That’s impossible for leading or trailing space.