将文件存储在数据库与文件系统中 [英] Storing files in database Vs file system

查看:87
本文介绍了将文件存储在数据库与文件系统中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一位客户要求文档管理系统来获取数千种不同格式的文档即pdf,doc,docx等.我的问题是在数据库或文件系统中存储此文件的最佳方法是什么?在这两种方法之间保护文档的安全性有多容易?

one of my customer ask for a Document Management System for some thousands of document in different format i.e. pdf, doc, docx etc. My question is what is the best way to store this file in database or in file system? How easy to secure a document between the two approach?.

快速检索文件是关键要求.

Fast retrieval of the files is the key requirement..

如果有帮助,请使用mysql

am using mysql if that helps

致谢.

推荐答案

您可能希望将其直接存储到文件系统中.

You might want to store it directly into filesystem.

在使用文件系统时,请注意:

When using filesystem careful with :

  • 机密性::将文档放在Apache文档根目录之外.然后,您的PHP控制器将输出文档.
  • 带斜线的路径:不要在同一目录中存储数千个文档,请创建不同的目录.例如,您可以在文件名上使用散列进行分片.例如/documents/A/F/B/AFB43677267ABCEF5786692/myfile.pdf.
  • 节点号:如果存储许多小文件(如果大多数情况下存储PDF和Office文档,则可能不会用完inode).
  • Confidentiality : Put documents outside of your Apache Document Root. Then a PHP Controller of yours will output documents.
  • Sharded path : do not store thousands of documents in the same directory, make differents directories. You can shard with a Hash on the Filename for example. Such as /documents/A/F/B/AFB43677267ABCEF5786692/myfile.pdf.
  • Inode number : You can run out of inodes if you store a lot of small files (might not be your case if storing mostly PDF and office documents).

如果您需要搜索这些文档(日期/标题/等),则可能需要将元数据存储到数据库中以获得更好的性能.

If you need to search for these documents (date/title/etc...) you may want to store metadata into a database for better performances.

FYI,文件系统列类型(类似于混合类型),但目前MySQL 没有替代.

FYI, in this question MS SQL Server has FILESYSTEM column type (like an hybrid), but at the moment MySQL doesn't have an alternative.

这篇关于将文件存储在数据库与文件系统中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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