fix(aws): preserve binary S3 object bodies - #225
Open
kamal wants to merge 2 commits into
Open
Conversation
Contributor
|
@kamal is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
S3 uploads retain their exact bytes, and HEAD responses preserve the object size required by download clients.
Why
S3 object uploads currently pass through
Request.text()andResponse.text(). Arbitrary binary objects are therefore decoded as UTF-8 and invalid bytes are replaced, corrupting images and other binary files.An empty streamed HEAD response also causes Bun to replace Content-Length with chunked encoding. Ruby S3 download clients then lack the object size they need. The shared HTTP-layer fix preserves that metadata without sending a response body.
Prior work
This builds on and credits #53 by @zaru, which first identified the binary PUT/GET corruption and proposed base64-backed storage. This version applies that fix to the current S3 route structure, also covers presigned POST uploads and copied objects, names the stored representation
body_base64, and exercises the behavior through the real AWS SDK with an SSE-S3 request.Testing
partNumber=1query.