坏主意创建为每个用户的文件夹? [英] Bad idea to create a folder for every user?

查看:152
本文介绍了坏主意创建为每个用户的文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否这将是一个糟糕的主意,以创建一个文件夹为每个用户。因此,对于每个用户的任何图像将与img.mysite.com/UserId/image.jpg访问

I am wondering if it would be a bad idea to create a folder for every user. So any images for each user would be accessed with img.mysite.com/UserId/image.jpg

推荐答案

这可能成长为目录的数量巨大,所以采取谨慎作为的一些文件系统限制在一个目录的子目录的数目。是很常见的产生的内容分解为多个目录。您可以按日期做,或打破一些标识符(哈希值,或图像的自动增量ID号码)来创建一个更深层次的目录结构。例如:

This could grow to be a huge number of directories, so take caution as some filesystems limit the number of subdirectories in a single directory. It is common to break up generated content into multiple directories. You could do it by date, or break up some identifier (a hash, or the image's autoincremented ID number) to create a deeper directory structure. Example:


  • 头像/ 000 /(图像1-999)

  • 头像/ 001 /(1000-1999图片)

  • 头像/ 002 /(图像2000-2999)

AKA目录preFIX是地板(ID / 1000)

AKA the directory prefix is floor(ID / 1000).

有可能是从你的文件系统抽象你的URI反正的情况下,所以它并没有真正身在何处的文件存储在后端,除非你是程序员。

There's probably a case for abstracting your URIs from your filesystem anyway, so it doesn't really matter where the files are stored on the backend, except to you as a programmer.

这篇关于坏主意创建为每个用户的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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