在数据库上保存base64字符串是一种好习惯吗? [英] Is it a good practice to save a base64 string on the Database?
问题描述
当用户可以将图像发送到我的网络服务时,我正在开发一个android应用程序.
i'm developing an android application when the user can send a image to my webservice.
当前在我的Web服务上,我得到一个Base64字符串并将其保存在数据库的表中.
Currently on my WebService i get a Base64 string and save it in a table on my database.
我的问题:这是一种好习惯吗?因为据我所知Base64字符串是一个很重的字符串.我担心的是数据库性能,例如当此表变得大于10000 ... 100000条记录时.
还是应该避免这种行为?
例如:Isntead不在数据库上存储Base64字符串,我可以恢复该图像并仅将URL保存在我的数据库中.
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:数据库是SqlServer
谢谢你们的帮助
Ps: The database is SqlServer
Thanks for the help guys
推荐答案
要回答您的问题,我认为这不是好习惯.
To answer your question, I think it's not good practice.
这在很大程度上取决于您将如何使用可能会加载的图像.然后,请记住( base64编码可使文件大小比其原始二进制表示大33%). 最好的方法是写入图像,然后将其位置保存在数据库中.
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.
请查看此帖子帮助.
这篇关于在数据库上保存base64字符串是一种好习惯吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!