manage uploaded files in database or file system?

限于喜欢 提交于 2019-11-28 08:49:43

问题


I'm going to incorporate the feature for my users to upload small files which are under 2mb (jpg, gif, pdf and docs). For page loading times purposes and generally managing files in future, can you recommend is it best to have the files uploaded to the filesystem (and link to it via the database) or upload to the database directly as a BLOB?

Thanks for any help. Dan


回答1:


From my point of view, file system is the best choice.

  1. Your database is not getting oversized because of BLOB fields
  2. You store only filenames as strings and you possibly can index on them (if you give meaningful names to your files)
  3. If you run out of space it is much easier to plug new HDD than migrate your DB.

The only drawback here is that someone (even you) can accidentally delete files much easier than BLOB fields.




回答2:


There are pros and cons for both approaches. Keeping files in DB will make management much simpler. From another side, files stored on filesystem can be delivered more effectively, saving IO and CPU resources.



来源:https://stackoverflow.com/questions/3707629/manage-uploaded-files-in-database-or-file-system

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