Storing Image File (binary) vs Image Base64 in Database

khophi

KhoPhi

Posted on April 30, 2018

Storing Image File (binary) vs Image Base64 in Database

Using frameworks like Django, the file is saved onto the harddrive, and a link pointing to the file is rather stored in the Database, which is fine.

In my current API approach for uploading content, I submit the form, the part where there are images using the standard form data posting (the usual multipart/form-data).

So I simply cook up a payload that mimics the usual form-data submit using Angular, then push to an endpoint that accepts the form data submission.

Recently, I'm thinking of going full base64 images.

As in,

  • User selects image to upload
  • Behind the scenes (on the browser), I encode the image to base64 string
  • User submits form, then the usual JSON payload is sent with the image field as base64

So something like:

{ data: 'string'
  image: 'base64 string'
}
Enter fullscreen mode Exit fullscreen mode

I've done the base64 image approach some time ago, and it was great (at least to me).

Are there any performance issues with going with base64 image strings for storage in Database? Any caveats to look out for?

💖 💪 🙅 🚩
khophi
KhoPhi

Posted on April 30, 2018

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related