You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using FormDataEncoder to encode data objects, specifically JPEG image data, the data gets corrupted.
To Reproduce
This can easily be reproduced by feeding JPEG image data into FormDataEncoder's encode function, then feeding it's output into FormDataDecoder's decode function and comparing the input data with the output data.
The comparison fails indicating that the original data is not equal to the decoded data.
When inspecting the bytes it shows a ~90% increase in size. @Joannis suggested one can expect such increase with base64 encoding while @vzsg was more specific pointing out that base64's "expanded size" is 4:3 not 3:2.
@vzsg also expressed concern that the encode method returns a String instead of Data as binary files may not be valid UTF-8.
Describe the bug
When using
FormDataEncoder
to encode data objects, specifically JPEG image data, the data gets corrupted.To Reproduce
This can easily be reproduced by feeding JPEG image data into
FormDataEncoder
's encode function, then feeding it's output intoFormDataDecoder
's decode function and comparing the input data with the output data.The comparison fails indicating that the original data is not equal to the decoded data.
When inspecting the bytes it shows a ~90% increase in size. @Joannis suggested one can expect such increase with base64 encoding while @vzsg was more specific pointing out that base64's "expanded size" is 4:3 not 3:2.
@vzsg also expressed concern that the encode method returns a String instead of Data as binary files may not be valid UTF-8.
Expected behavior
The decoded data is equal to the original data.
Environment
multipart-kit version: 4.6.0
swift-tools-version: 5.7
macOS version: 14.2.1
The text was updated successfully, but these errors were encountered: