Skip to content
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

Support for checksumAlgorithm #1123

Closed
miguelfteixeira opened this issue Apr 10, 2023 · 2 comments · Fixed by #1202
Closed

Support for checksumAlgorithm #1123

miguelfteixeira opened this issue Apr 10, 2023 · 2 comments · Fixed by #1202
Assignees
Labels

Comments

@miguelfteixeira
Copy link

While using checksumAlgorithm as part of the PutObjectRequest.builder() I've noticed that when I do a getObject operation using S3Mock not only I don't have access to the generated checksum (via response.response().checksumSHA256()) but also the response.contentEncoding is set to aws-chunked. Resulting in not being able to call ImageIO.read(response) when I call PutObject with checksumAlgorithm.

Everything works as expected when I remove the call to checksumAlgorithm or I use a real S3 Client, as in, response.contentEncoding is null and ImageIO.read(response) works.

It's the first I use this library and I've no experience with Kotlin (this is an existing project, I've just added the checksumAlgorithm). Is there any plans to provide support for this operation?

@afranken
Copy link
Member

@miguelfteixeira checksums are indeed currently not supported in S3Mock.

it should be possible to add support in a future release, let me look into it.

@afranken
Copy link
Member

Looked into this a bit.
First I thought that the S3 backend would need to calculate the checksum, but it's actually the client that calculates the checksum and then sends it to the backend - as part of the request body.

When uploading the sample file
ttps://github.com/adobe/S3Mock/blob/main/integration-tests/src/test/resources/sampleFile.txt

the body looks like this:

24
## sample test file ##

demo=content
0
x-amz-checksum-crc32:I6zdvg==

I'll have to test with more data to evaluate the pattern and build an inputstream similar to com.adobe.testing.s3mock.util.AwsChunkedDecodingInputStream where we skip the bytes we do not want to persist as binary data in the backend, and parse the checksum so we can return it in the API for later requests.

@afranken afranken mentioned this issue Jul 1, 2023
2 tasks
afranken added a commit that referenced this issue Jul 2, 2023
Both "ChecksumAlgorithm" where the SDK calculates the checksum and
embeds it into the request body, and checksum headers are supported.

Fixes #1123
afranken added a commit that referenced this issue Jul 2, 2023
Both "ChecksumAlgorithm" where the SDK calculates the checksum and
embeds it into the request body, and checksum headers are supported.

Fixes #1123
afranken added a commit that referenced this issue Jul 3, 2023
Signed requests including checksums need special handling.

Fixes #1123
afranken added a commit that referenced this issue Jul 4, 2023
afranken added a commit that referenced this issue Jul 4, 2023
Both "ChecksumAlgorithm" where the SDK calculates the checksum and
embeds it into the request body, and checksum headers are supported.

Fixes #1123
afranken added a commit that referenced this issue Jul 4, 2023
Signed requests including checksums need special handling.

Fixes #1123
afranken added a commit that referenced this issue Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants