如何像 BaseCamp 文档管理器一样在数据库和磁盘中创建同一文件的版本

发布于 2024-12-09 21:03:12 字数 848 浏览 0 评论 0原文

如果您使用过Basecamp,您还可以在此处查找演示。我喜欢当同一个文件上传两次时创建版本的功能,[可选地用户指定将文件创建为新版本]。您认为这些文件如何在 DATABASE 中作为记录维护,在 DISK 中作为文件维护。根据我的检查,文件的保存方式似乎如下所示

结构

[user_folder]
 [project_name]
  [file_name]
    [V1/V2/V3]

例如考虑以下

示例

  1. 用户名是“mak”

  2. 项目名称“izord”和

  3. 文件名为“base.html”

它有两个版本,这是目录结构,

   [mak]
     [izord]
      [base]
        [V1]
         base.html
        [V2]
          base.html

我的假设可能是错误的,但这就是我来这里纠正它的原因。

问题

  1. 您认为在这种情况下我如何组织磁盘上的文件
  2. 您是否有任何预制的、已经开发的表结构来保存文件详细信息?
  3. 如何像演示视频中那样根据字母表对表中的文件进行排序。他们是否维护着另一张桌子?

If you've used Basecamp there is a documents manager page you can also find a demo here. I liked the feature of creating versions when same file gets uploaded twice,[optionally user specifies to create the file as new version]. How do you think the files are maintained in the DATABASE as records and in DISK as files. From my inspection it seems the files are saved like below

Structure

[user_folder]
 [project_name]
  [file_name]
    [V1/V2/V3]

for example taking below consideration

Example

  1. user name is "mak"

  2. project name "izord" and

  3. file name is "base.html"

it has 2 versions here is directory structure

   [mak]
     [izord]
      [base]
        [V1]
         base.html
        [V2]
          base.html

i might be wrong in my assumptions, but that's why i am here to get it corrected.

Question

  1. How do you think i can organize files on disk in this situation
  2. Do you have any premade, already developed table structure for saving file details?
  3. How does one sort files from table based on alphabets like the one in demo video. Are they maintaining sort of another table?

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

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

发布评论

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

评论(1

不羁少年 2024-12-16 21:03:12

首先,我很确定他们将文件存储在 S3 中,因此请考虑到这一点。

至于数据库结构,我会有类似的东西

Account:      ID
Project:      ID, AccountID
File:         ID, ProjectID, Name, ContentType, CurrentRevision
FileRevision: ID, FileID, ContentLength, AmazonS3Key, CreatedAt, CreatedBy

,然后将每个文件存储在 /// 下“目录”(S3 中没有实际的目录,但它们是用正斜杠模拟的)。文件内容位于适当的目录中:

<bucket>/<account-id>/<project-id>/<file-name>
  v1
  v2
  ...
  v13

上传文件的新版本只需将 v 条目添加到 S3 存储即可。

另请注意,公开帐户和项目的 ID 可能不是一个好主意,因此我会使用这些哈希值: ///<文件名>

First of all, I'm pretty sure they store files in S3, so take this into account.

As for database structure, I'd have it something like

Account:      ID
Project:      ID, AccountID
File:         ID, ProjectID, Name, ContentType, CurrentRevision
FileRevision: ID, FileID, ContentLength, AmazonS3Key, CreatedAt, CreatedBy

and then store each file under <bucket>/<account-id>/<project-id>/<file-name> "directory" (there are no actual directories in S3, but they are emulated with forward slashes). File content goes inside an appropriate directory:

<bucket>/<account-id>/<project-id>/<file-name>
  v1
  v2
  ...
  v13

Uploading a new revision of a file is simply a matter of adding a v<File.CurrentRevision + 1> entry to an S3 storage.

Also note that disclosing IDs of accounts and projects might not be a good idea, so I'd go with hashes of those: <bucket>/<md5(account-id + salt)>/<md5(project-id + salt)>/<file-name>

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