There are some very good questions here on SO about file management and storing within a large project.

关于文件管理和存储在大型项目中,有一些非常好的问题。

Storing Images in DB - Yea or Nay?
Would you store binary data in database or in file system?

在DB中存储图像 - 是还是不?您会将二进制数据存储在数据库或文件系统中吗?

The first one having some great insights and in my project i've decided to go the file route and not the DB route.

第一个有一些很好的见解,在我的项目中,我决定采用文件路径而不是DB路由。

A major point against using the filesystem is backup. But in our system we have a great backup scheme so i am not worried about that.

反对使用文件系统的一个主要问题是备份。但在我们的系统中,我们有一个很好的备份方案,所以我并不担心。

The next path is how to store the actual files. And I've thought about having the files' location static at all times and create a virtual directory system in the database side of things. So links to the file don't change.

下一个路径是如何存储实际文件。而且我一直在考虑让文件的位置始终保持静态,并在数据库方面创建虚拟目录系统。因此,文件的链接不会改变。

The system i am building will have one global file management so all files are accessible to all users. But many that have gone the file route talk about physical directory size (if all the files are within one directory for example)

我正在构建的系统将具有一个全局文件管理,因此所有用户都可以访问所有文件。但许多已经走过文件路径的人谈论物理目录大小(例如,如果所有文件都在一个目录中)

So my question is, what are some tips or best practice methods in creating folders for these static files, or if i shouldn't go the virtual directory route at all.

所以我的问题是,为这些静态文件创建文件夹有什么技巧或最佳实践方法,或者我根本不应该去虚拟目录路由。

(the project is on the LAMP stack (PHP) if that helps at all)

(该项目在LAMP堆栈(PHP)上,如果它有帮助的话)

6 个解决方案

#1


11

One way is to assign a unique number to each file and use it to look up the actual file location. Then you an use that number to distribute files in different directories in the filesystem. For example you could use something like this scheme:

一种方法是为每个文件分配一个唯一的编号,并使用它来查找实际的文件位置。然后,您使用该编号将文件分发到文件系统中的不同目录中。例如,您可以使用类似此方案的内容:

/images/{0}/{1}/{2}

{0}: file_number % 100
{1}: (file_number / 100) % 100
{2}: file_number

{0}:file_number%100 {1} :( file_number / 100)%100 {2}:file_number

更多相关文章

  1. 权限被拒绝:/var/www/abc/.htaccess pcfg_openfile:无法检查htacce
  2. 【CodeBase】PHP检查未知媒体文件的格式
  3. php 读取文本文件
  4. 如何打开名称中包含特殊字符的文件
  5. 如何将项添加到json文件格式化数组
  6. 如何实现分布式文件上传解决方案?
  7. phpstorm取消自动保存并标识修改的文件为星星标记
  8. 在HTTP 1.0中,状态码401的含义是什么;如果返回“找不到文件”的提
  9. thinkphp整合系列之tcpdf类生成pdf文件

随机推荐

  1. oralce 解除锁定的表
  2. 文件转换 - .mwb到.sql文件
  3. 返回没有匹配条目的所有日期
  4. SQL2000数据库脱机/只读/紧急模式 修复
  5. Oracle 00932. 00000 - “不一致的数据
  6. java中sql查询条件为中文时,rs.next为fals
  7. 没有必要去指定SqlSessionFactory或SqlSe
  8. sqlserver 存储过程 递归查询分组+hier
  9. 我的MSSQL2000数据库自从我的系统从XPHOM
  10. 如何从多表中不存在的表中获取不同的值