Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a good practice to save a base64 string on the Database?

i'm developing an android application when the user can send a image to my webservice.

Currently on my WebService i get a Base64 string and save it in a table on my database.

My question: Is that a good practice? Because as far as i know the Base64 string is a heavy string. My concern is about the db performance, like when this table gets bigger than 10000...100000 records.
Or should i avoid this behavior?
Eg.: Isntead off store the Base64 string on the database, i could recover the image and save only the URL at my db.

Ps: The database is SqlServer


Thanks for the help guys

like image 698
GuiPab Avatar asked Sep 17 '15 12:09

GuiPab


People also ask

Is it good to store Base64 in DB?

While base64 is fine for transport, do not store your images base64 encoded. Base64 provides no checksum or anything of any value for storage. Base64 encoding increases the storage requirement by 33% over a raw binary format.

Is Base64 string safe?

Base64 is not an encryption, it is an encoding. It's role is to make sure the password can be stored in the database nicely and special characters aren't a problem. It does nothing to protect the password. From security standpoint, it is exactly the same as storing it without any encoding.

Why is Base64 inefficient?

Base64 is apparently wasteful because we use just 64 different values per byte, whereas a byte can represent 256 different characters. That is, we use bytes (which are 8-bit words) as 6-bit words. There is a waste of 2 bits for each 8 bits of transmission data.


1 Answers

To answer your question, I think it's not good practice.

It depends largely upon how you will use these images you will probably load. Then, remember (base64 encoding makes file sizes roughly 33% larger than their original binary representations). The best way would be writing the image and then saving its location in the database.

Check out this post as it maybe help.

like image 70
MusicsCordova Avatar answered Sep 21 '22 00:09

MusicsCordova