且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-10-08 14:54:16

一般来说,***将文件存储在文件系统上.文件系统已经针对存储文件进行了调整.但是,这确实有其缺点,特别是在管理、备份、恢复方面,并且在数据库中的 varchar 文件路径字段与文件系统中的文件之间存在某种脆弱的联系.你用的是什么数据库系统?我认为如果您使用的是 SQL Server 2008,那么新的 FileStream 类型为在该数据库中存储文件提供了一种非常好的方法.

In general, it is better to store files on the file system. File systems are already tuned for storing files. However, this does have its drawbacks, particularly in terms of management, backup, restore and it is somewhat of a flimsy tie between a varchar file path field in the database and a file in the file system. What database system are you using? I think if you are using SQL Server 2008, that the new FileStream type gives a very good method for storing files in that database.

请注意,我实际上是在更一般地谈论在数据库中存储文件.尝试将您打算在 HTML 页面上显示的图像存储在数据库中会涉及一些额外的复杂性.

Note I'm really talking about more generally about storing files in the database. There is some extra complexity involved in trying to store images you intend to display on HTML pages in the database.