所以我用的是一个在数据库中大量存储图像的应用程序。你对此有什么看法?我更倾向于将位置存储在文件系统中,而不是直接存储在DB中。
你认为优点和缺点是什么?
所以我用的是一个在数据库中大量存储图像的应用程序。你对此有什么看法?我更倾向于将位置存储在文件系统中,而不是直接存储在DB中。
你认为优点和缺点是什么?
当前回答
在我当前的应用程序中,我两者都在做。当用户确定要附加到记录上的图像时,我使用ImageMagick将其调整为适合在屏幕上显示的大小(对于我的应用程序约为300x300),并将其存储在数据库中以方便访问,但随后还将用户的原始文件复制到网络共享,以便它可用于需要更高分辨率的应用程序(如打印)。
(还有一些其他的因素:Navision将只显示BMP,所以当我调整它的大小时,我也转换为BMP存储,数据库被复制到远程站点,在那里能够显示图像是有用的。打印工作只在总部进行,所以我不需要复制原始文件。
其他回答
这可能有点不切实际,但如果你正在使用(或计划使用)SQL Server 2008,我建议你看看新的FileStream数据类型。
FileStream解决了在DB中存储文件的大部分问题:
blob实际上以文件的形式存储在文件夹中。 可以使用数据库连接或通过文件系统访问blob。 备份是集成的。 迁移“就是管用”。
然而,SQL的“透明数据加密”不加密FileStream对象,因此如果考虑到这一点,最好将它们存储为varbinary。
摘自MSDN文章:
Transact-SQL语句可以插入、更新、查询、搜索和备份FILESTREAM数据。Win32文件系统接口提供对数据的流访问。 FILESTREAM使用NT系统缓存来缓存文件数据。这有助于减少FILESTREAM数据对数据库引擎性能的影响。SQL Server缓冲池未被使用;因此,该内存可用于查询处理。
我负责一些管理许多TB图像的应用程序。我们发现在数据库中存储文件路径是最好的。
这里有几个问题:
database storage is usually more expensive than file system storage you can super-accelerate file system access with standard off the shelf products for example, many web servers use the operating system's sendfile() system call to asynchronously send a file directly from the file system to the network interface. Images stored in a database don't benefit from this optimization. things like web servers, etc, need no special coding or processing to access images in the file system databases win out where transactional integrity between the image and metadata are important. it is more complex to manage integrity between db metadata and file system data it is difficult (within the context of a web application) to guarantee data has been flushed to disk on the filesystem
我更喜欢将图像路径存储在DB中,并将图像存储在文件系统中(在服务器之间使用rsync以保持所有内容的合理最新)。
然而,我所做的一些内容管理系统的工作需要在CMS中使用图像,原因有几个——可见性控制(因此资产被保留到新闻稿发布之前)、版本控制、重新格式化(一些CMS将动态调整缩略图的大小)以及将图像链接到所见即所得页面的易用性。
因此,我的经验法则是始终将应用程序的内容保存在文件系统中,除非它是CMS驱动的。
假设:应用程序是基于web的
我很惊讶没有人真正提到这一点……委托给其他专家->使用第三方映像/文件托管提供商。
将文件存储在付费的在线服务上,比如
Amazon S3 Moso云存储
另一个StackOverflow线程在这里讨论这个。
这篇文章解释了为什么你应该使用第三方托管提供商。
太值得了。它们能有效地储存。没有带宽从你的服务器上传到客户端请求等等。
I have worked with many digital storage systems and they all store digital objects on the file system. They tend to use a branch approach, so there will be an archive tree on the file system, often starting with year of entry e.g. 2009, subdirectory will be month e.g. 8 for August, next directory will be day e.g. 11 and sometimes they will use hour as well, the file will then be named with the records persistent ID. Using BLOBS has its advantages and I have heard of it being used often in the IT parts of the chemical industry for storing thousands or millions of photographs and diagrams. It can provide more granular security, a single method of backup, potentially better data integrity and improved inter media searching, Oracle has many features for this within the package they used to call Intermedia (I think it is called something else now). The file system can also have granular security provided through a system such as XACML or another XML type security object. See D Space of Fedora Object Store for examples.