fix: treat application/octet-stream as a binary encoding #1587
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.
Description
This extends the current workaround of converting the payloads of certain MIME types that are known to have binary data, hence the need to be encoded as a binary string.
Motivation and Context
This resolves an issue where binary encoded payloads like
application/octet-stream
in the body are being converted into string withutf8
as an encoding, causing data corruption when it reaches the function handler.Adding more MIME types that are considered to be binary files seems a bit fragile so I think it's best to add just the
application/octet-stream
MIME type as it solves the use case where someone would want to send a file that isn't part of amultipart/form-data
.The real solution is to simulate what the actual API Gateway does which is to convert the payload into a base64 encoded string but I'm not sure what the consequence is yet for this repo so let's stick with this for now.