multipart-kit icon indicating copy to clipboard operation
multipart-kit copied to clipboard

Add encoding function that returns Data. Fixes #94

Open andrew804 opened this issue 11 months ago • 3 comments

Added encodeToData function to FormDataEncoder which returns Data instead of String. Added serializeToData function to MultipartSerializer which returns Data instead of String. Added decode function to FormDataDecoder which accepts Data as input. Added test for encoding and decoding a jpeg image with the new Data functions. Added test for encoding and decoding a jpeg image with the original String functions. Added image.jpeg in /Utilities

This PR fixes https://github.com/vapor/multipart-kit/issues/94

andrew804 avatar Mar 01 '24 22:03 andrew804

Thank you for your fast feedback! Hopefully I covered everything - please let me know if not or if you have any further comments.

andrew804 avatar Mar 02 '24 14:03 andrew804

@andrew804 Looks like this is failing in CI

0xTim avatar Mar 20 '24 14:03 0xTim

@0xTim the failing test is the one that tests for encoding and decoding a jpeg image with the original string functions which highlights the original bug ie the original bug is still present, using the string encoding and decoding functions still corrupts the data.

Therefore I could either 1) add a warning in the documentation to not use the string functions and instead use the data functions for encoding and decoding images, then just remove the failing test or 2) remove the troublesome string functions entirely and include this PR in the next major release.

Unless you have any other suggestion, what would you prefer?

andrew804 avatar Mar 26 '24 08:03 andrew804