User images - database vs. filesystem storage

你说的曾经没有我的故事 提交于 2019-11-26 16:48:24
X-Istence

Your question has been answered before on StackOverflow:

Store pictures as files or in the database for a web app

Including many other duplicate questions!

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.

Edit: 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.

Filesystem is good, but is not practical with more than 3000 image per folder. It's better to write automatic folder creation for every 3000 images blocks.

data redundency and inconsistency difficulty in accessing of data data isolation integrity constraints atomicity problem concurrent access and anomalies (updation security problem

For fixed (non changing) content such as photos, videos, etc. filesystems won't be able to scale especially if you have lots of files in a directory and performance will really suffer. A better option is to use object storage technology which stores the image as an object and puts the associated metadata in the database automatically.

How about storing doc, pdf, xls, jpg files? Which one recommended?

I am going to work on a document management system which might store 10000 files but the problem is I am very worry about virus spreading if we use file system technique.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!