在数据库上保存base64字符串是一个好习惯吗?

时间:2020-12-06 16:53:50

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

当用户可以将图像发送到我的web服务时,我正在开发一个Android应用程序。

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

目前在我的WebService上,我得到一个Base64字符串并将其保存在我的数据库的表中。

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.

我的问题:这是一个好习惯吗?因为据我所知,Base64字符串是一个重字符串。我担心的是db性能,就像这个表大于10000 ... 100000条记录一样。或者我应该避免这种行为?例如:Isntead将Base64字符串存储在数据库中,我可以恢复映像并仅在我的数据库中保存URL。

Ps: The database is SqlServer


Thanks for the help guys

Ps:数据库是SqlServer感谢帮助人员

2 个解决方案

#1


5  

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.

这在很大程度上取决于您将如何使用这些图像,您可能会加载。然后,请记住(base64编码使文件大小比其原始二进制表示大约33%)。最好的方法是编写图像,然后将其位置保存在数据库中。

Check out this post as it maybe help.

看看这篇文章,因为它可能有所帮助。

#2


1  

i think using base64 encoding is very useful for saving URLs in the database. The big size for transmitted image is not good idea and not necessary.

我认为使用base64编码对于保存数据库中的URL非常有用。传输图像的大尺寸并不是一个好主意,也没有必要。

#1


5  

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.

这在很大程度上取决于您将如何使用这些图像,您可能会加载。然后,请记住(base64编码使文件大小比其原始二进制表示大约33%)。最好的方法是编写图像,然后将其位置保存在数据库中。

Check out this post as it maybe help.

看看这篇文章,因为它可能有所帮助。

#2


1  

i think using base64 encoding is very useful for saving URLs in the database. The big size for transmitted image is not good idea and not necessary.

我认为使用base64编码对于保存数据库中的URL非常有用。传输图像的大尺寸并不是一个好主意,也没有必要。