Is using multipart/form-data any better then JSON + Base64?

Should I just have the client upload JSON with the fields encoded in
base64, and take the 25% hit?

The hit will be 33% since 4/3=1.33.

Or should I have the JSON object being represented as some sort of
“json” variable in a Multipart/form-data request, and have the binary
files to be uploaded as another variable?

This should work.

You might also consider this approach: send all files using multipart, then get some identificators of files as a response. Put this identificators in your json and send it anyway you like. This approach might be beneficial if you have many scenarios in which you send files: you might always send them to the server with the same request, then get their identificators; after that do with them what you like.

Leave a Comment