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

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

问题描述

我的一位客户要求使用 文档管理系统来处理数千份不同格式的文档即 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 Controller 将输出文档.
  • 分片路径:不要在同一个目录中存储数千个文档,创建不同的目录.例如,您可以在文件名上使用哈希进行分片.如/documents/A/F/B/AFB43677267ABCEF5786692/myfile.pdf.
  • inode 编号:如果您存储大量小文件,您可能会用完 inode(如果主要存储 PDF 和办公文档,则可能不是这种情况).
  • 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.

仅供参考,在这个问题中 MS SQL Server 有 FILESYSTEM 列类型(如混合),但目前 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.

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

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