要执行或不执行:将图像存储在数据库中 [英] To Do or Not to Do: Store Images in a Database
问题描述
在web应用程序的上下文中,我的老老板总是说在数据库中引用了一个图像,而不是图像本身。我倾向于同意,在数据库中存储一个url与图像本身是一个好主意,但在我现在工作,我们在数据库中存储了很多图像。
In the context of a web application, my old boss always said put a reference to an image in the database, not the image itself. I tend to agree that storing an url vs. the image itself in the DB is a good idea, but where I work now, we store a lot of images in the database.
我能想到的唯一原因可能是更安全?您不希望有人直接链接到网址?但是如果是这样,你总是可以有网站/服务器处理图像,像asp.net中的处理程序,以便用户需要验证来查看图像。我也认为性能会受到伤害从数据库中拉出图像。任何其他原因为什么它可能是一个好/不是好的主意在数据库中存储图像?
The only reason I can think of is perhaps it's more secure? You don't want someone having a direct link to an url? But if that is the case, you can always have the web site/server handle images, like handlers in asp.net so that a user needs to authenticate to view the image. I'm also thinking performance would be hurt by pulling out the images from the database. Any other reasons why it might be a good/not so good idea to store images in a database?
完全重复: 用户图片:数据库或文件系统存储?
确切重复: 在数据库中保存图片:是或否?
确切重复: 我应该存储我的图片在数据库或文件夹中?
确切重复: 将二进制数据存储在数据库或文件夹中?
确切重复: 将图片存储为文件或者将数据库存储为网络应用?
确切重复: 存储少量图片:blob或fs?
确切重复: 在文件系统或数据库中存储图像?
Exact Duplicate: User Images: Database or filesystem storage?
Exact Duplicate: Storing images in database: Yea or nay?
Exact Duplicate: Should I store my images in the database or folders?
Exact Duplicate: Would you store binary data in database or folders?
Exact Duplicate: Store pictures as files or or the database for a web app?
Exact Duplicate: Storing a small number of images: blob or fs?
Exact Duplicate: store image in filesystem or database?
推荐答案
如果您偶尔需要检索图片,且该图片必须在几个不同的网络服务器上可用。但我认为这是很多。
If you on occasion need to retrieve an image and it has to be available on several different web servers. But I think that's pretty much it.
- 如果不需要在多个服务器上可用,最好将它们放在文件系统中。
- 如果它必须在多个服务器上可用,并且系统中实际上存在某种负载,则需要某种类型的分布式存储。
我们在这里谈论一个边缘情况,您可以通过利用数据库避免给您的系统增加额外的复杂性。
We're talking an edge case here, where you can avoid adding an additional level of complexity to your system by leveraging the database.
除此之外,不要这样做。
Other than that, don't do it.
这篇关于要执行或不执行:将图像存储在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!