将图像(jpg,gif,png)存储在文件系统或DB中? [英] Store images(jpg,gif,png) in filesystem or DB?

查看:232
本文介绍了将图像(jpg,gif,png)存储在文件系统或DB中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能的重复项:

哪个更安全:文件系统或数据库?

用户映像 - 数据库与文件系统存储

Possible Duplicates:
Which is more secure: filesystem or database?
User images - database vs. filesystem storage
store image in database or in a system file ?



我不能决定我应该跟着哪一个。你能给点意见吗?我应该将我的图像存储在文件系统或DB中吗? (我想阻止其他人窃取我的图片)

I can't decide which one I should follow. Can you guys give some opinions? Should I store my images in the file-system or DB? (I would like to prevent others from stealing my images)

当您回答这个问题时,请包括安全性,表演等的比较。

When you answer this question, please include comparisons of the security, performances etc.

感谢。

精确重复用户图片:数据库或文件系统存储?

精确复制在数据库中存储图片:是或否?

完全重复: 我应该将我的图片存储在数据库或文件夹中吗?

确切重复: 是否将二进制数据存储在数据库或文件夹中?

完全重复: 将图片存储为文件或网络应用的数据库?

确切重复: 存储少量图像:blob或fs?

精确复制:
将图片存储在文件系统或数据库中。 / p>

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?

推荐答案

将图像移动到数据库中,并编写代码来提取图像可能比它更有价值。

Moving your images into a database and writing the code to extract the image may be more hassle than it's worth. It will all go back to the business requirements surrounding the need to protect the images, or the requirement for performance.

我建议坚持尝试和真正的系统,以保护图像,将文件路径或目录位置存储在DB中,并将这些文件保留在磁盘上。原因如下:

I'd suggest sticking to the tried and true system of storing the filepath or directory location in the DB, and keeping the files on disk. Here's why:


  • 文件系统更容易维护。一些想法必须放入图像的结构和组织。即每个客户的目录,每个[Attribute-X]的子目录和每个[Attribute-Y]的另一个子文件夹。在一个目录中保存太多图片将会减慢文件访问速度(即数十万)。

  • 如果存储在数据库中的想法是针对文件系统丢失的对策,即一个磁盘下来,或一个目录被意外删除),那么我会反对的建议,当你使用源代码控制,它是没有问题,检索任何丢失/丢失/删除文件。

  • 如果您需要扩展和移动到内容分发方案,您必须移回到文件系统或执行大量提取以推送给提供商。

  • 它也伴随着说:在数据库中保留结构化数据。 Microsoft有一篇有关管理非结构化数据

  • 如果安全性是需要解决的问题,则文件系统具有包含ACL的整个结构。

  • A filesystem is easier to maintain. Some thought has to be put into the structure and organization of the images. i.e. a directory for each customer, and a subdirectory for each [Attribute-X] and another subfolder for each [Attribute-Y]. Keeping too many images in one directory will end up slowing down the file access (i.e. hundreds of thousands)
  • If the idea of storing in a DB is a counter-measure against filesystem loss, (i.e. a disk goes down, or a directory is deleted by accident), then I'd counter with the suggestions that when you use source control, it's no problem to retrieve any lost/missing/delete files.
  • If you ever need to scale and move to a content distribution scenario, you'd have to move out back to the filesystem or perform a big extract to push out to the providers.
  • It also goes with the saying: "keep structured data in a database". Microsoft has an article on Managing Unstructured Data.
  • If security is an issue to be addressed, the filesystem has a whole structure with ACLs. Reinventing the wheel on security may be out of scope in the business requirements.

此主题的大量讨论也可在以下网址找到: :

A large amount of discussion for this topic is also found at:

  • Question 3748
  • Question 561447

将您的图片存储为 varbinary 或某种blob(取决于你的平台),我建议它更多的麻烦比它的价值。您需要扩展的工作意味着更多的代码,您必须维护,单元测试和防御缺陷。

Having your images stored as varbinary or a blob of some kind (depending on your platform), I'd suggest it's more hassle than it's worth. The effort that you'll need to extend means more code that you'll have to maintain, unit test, and defend against defects.

如果您的环境可以支持SQL Server 2008,您可以在SQL 2008中使用他们新的FileStream数据类型获得两个世界的最佳结果。

If your environment can support SQL Server 2008, you can have the best of both worlds with their new FileStream datatype in SQL 2008.

  • An MSDN article is touting the FileStream datatype in SQL 2008 as high performance.
  • SQL Skills has a great article with some SQL 2008 Filestream performance measurements.
  • Here is an article addressing varbinary vs. FileStream and performance of both datatypes.
  • If you are a SQL Mag subscriber, you can see a great article at SQL Mag on SQL 2008 FileStream.
  • Microsoft Research article:To Blob or Not To Blob

世界情景与大用户基地像Flickr或Facebook。

I'd love to see studies in real-world scenarios with large user bases like Flickr or Facebook.

同样,这一切都可以回到您的业务需求。祝你好运!

Again, it all goes back to your business requirements. Good luck!

这篇关于将图像(jpg,gif,png)存储在文件系统或DB中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆