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
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With