php - Is it wise to store base64 encoded images inside a database? -
i'm making android application takes photo , push image (as base64 encoded string) php script, here i'll storing data image inside mysql database.
would wise store image inside database (since it's passed base64 string), better convert image , store on filesystem?
a base64 encoded image takes place (about 33% more binary equivalent).
mysql offers binary formats (blob, medium_blob), use them.
alternatively, people prefer store in db key file filesystem store more efficiently, if it's big image. that's solution prefer long term. use sha1 hash of file content form path file, have no double storage , it's easy retrieve record file if want (i use 3 level file tree, first 2 levels being made respectively first 2 characters , characters 3 , 4 of hash don't have many direct child of directory). note example logic of git storage.
the advantage of storing them in db you'll manage more backups, long project small. database offer cache, server , client too, it's hard decide priori fastest , difference won't big (i suppose don't make many concurrent write).
Comments
Post a Comment