android – Base64 image upload VS Binary image upload?-ThrowExceptions

Exception or error:

I want my mobile application to be able to upload an image to my server, in my case it’s a Rails 3.2.11 with nginx.

I read alot about Base64 encoding on client side and then decoding on the server side.

Why not just use binary upload with multipart headers on the http request?

Are the any pros / cons for each technic?

How to solve:

Base64 converts your data to an ASCII representation of the binary data. It allows you to embed your data in text streams such as JSON for example. Base64 increases the size of the data transferred by 33%.

multipart/form-data is the standard way of transferring binary data in HTTP requests. It allows you to use specific encodings / content types for each part you’d like to transfer. In my opinion, you should stick to multipart uploads unless you have specific requirements or device/SDK capabilities.


‘Why not just use binary upload with multipart headers on the http request?’ indeed why not 😉

Base64 image representation can be directly placed within html to render an image.

Binary takes up less space. And benefits from greater network effects and standardization. E.g. if you want to use amazon simple secure storage S3 you have to store a binary file. You can’t store a string you would need a key/value store e.g. redis.

Leave a Reply

Your email address will not be published. Required fields are marked *