将文件存储在在线文件管理器的目录中

发布于 2024-09-16 00:25:55 字数 391 浏览 15 评论 0原文

我有一个网站,允许人们将文件上传到他们的帐户,并且它们显示在列表中。所有用户的文件都存储在不同的服务器上,并且根据它们的受欢迎程度(它是一个文件托管站点)进行移动。

我想添加用户将文件分组到文件夹中的功能。我可以采用传统的路线,在硬盘驱动器上为服务器上的每个用户创建物理文件夹,并按预期横向排列它们。这样做的缺点是用户的文件将被绑定到单个服务器。如果该服务器开始运行空间(或者许多文件同时流行),那么缓解它就会变得非常棘手。

我想做的是保持文件的无状态性质,允许它们存储在任何文件服务器上,并简单地将文件夹 ID(除了拥有该文件的用户 ID 之外)与数据库中的每个文件一起存储。因此,当用户决定移动文件时,文件实际上不会移动到任何地方,您只需更改数据库中的文件夹 ID 即可。

这是个好主意吗?我使用php和mysql。

I have a site that allows people to upload files to their account, and they're displayed in a list. Files for all users are stored on different servers, and they move around based on how popular they are (its a file hosting site).

I want to add the ability for users to group files into folders. I could go the conventional route and create physical folders on the hard drive, for each user on the server, and transverse them as expected. The downside to that is the user's files will be bound to a single server. If that server starts running of space (or many files get popular at the same time), it will get very tricky to mitigate it.

What I thought about doing is keeping the stateless nature of files, allowing them to be stored on any of the file servers, and simply storing the folder ID (in addition to the user id who owns the file) with each file in the database. So when a user decides to move a file, it doesn't get physically moved anywhere, you just change the folder ID in the database.

Is that a good idea? I use php and mysql.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月寒剑心 2024-09-23 00:25:55

是的。

我没有看到任何缺点,除了可能对数据库有更多查询之外,但是通过对父文件夹 ID 进行正确的索引,这可能会比直接访问文件系统更快。

Yes, it is.

I don't see any downside, except maybe more queries to the database, but with proper indexing of the parent folder id, this will probably be faster than accessing the filesystem directly.

盛夏已如深秋| 2024-09-23 00:25:55

忘记文件夹,让用户标记他们的文件,每个文件多个标记。然后让他们查看标记为 X 的文件。这与虚拟文件夹的实现没有太大不同,但对用户来说更加灵活。

Forget about folders and let the users tag their files, multiple tags per file. Then let them view files tagged X. This isn't much different to implement than virtual folders but is much more flexible for the users.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文