Vb.Net文档存储
我正在尝试向我们的 AR 软件添加文档存储模块。
我将提示用户将文档/图像附加到他们的帐户。 然后,我会将此文件的副本放入我们的文件夹中,以便我们可以引用它,而不必依赖他们将文件保留在其原始位置。 该系统不使用数据库,而是使用多个平面文件。
我正在寻找有关如何在这些文件附加到我们的系统后处理这些文件的指导。
我应该如何存储这些附加文件?
我想我可以将文件复制到子目录,然后将其重命名为自动生成的编号,这样我们就不会出现重复项。 这样做的坏处是文件夹的内容可能会变得相当大。
大家有更好的办法吗? 我应该创建目录并存储它们......?
I am attempting to add a document storage module to our AR software.
I will be prompting the user to attach a doc/image to thier account. I will then put a copy of this file into our folder so that we can reference it without having to rely on them keeping the file in its original place. This system is not using a database but instead its using multiple flat files.
I am looking for guidance on how to handle these files once they have attached them to our system.
How should I store these attached files?
I was thinking I could copy the file over to a sub directory then renaming it to a auto-generated number so that we do not have duplicates. The bad thing about this, is the contents of the folder can get rather large.
Anyone have a better way? Should I create directories and store them...?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这听起来像是一个多用户系统。 您如何处理并发访问问题? 您对此的回答将极大地影响我们在这里告诉您的任何内容。
由于您没有对其他文件执行任何特殊操作来处理并发访问,因此我要做的就是在主数据文件夹下添加一个专门用于文档存储的新文件夹,并在其中写入用户文件。 此外,您还需要担心名称冲突。 为了解决这个问题,我将日期和用户名附加到原始文件名并采用该字符串的 md5 或 sha1 哈希值来命名每个文件。 然后将文件添加到其他数据文件中,以将哈希值映射到用户的原始文件名。
This sounds like a multi-user system. How are you handing concurrent access issues? Your answer to that will greatly influence anything we tell you here.
Since you aren't doing anything special with your other files to handle concurrent access, what I would do is add a new folder under your main data folder specifically for document storage, and write your user files there. Additionally, you need to worry about name collisions. To handle that, I'd name each file there with by appending the date and username to the original file name and taking the md5 or sha1 hash of that string. Then add a file to your other data files to map the hash values to original file names for users.
考虑到您的限制(并假设总用户数量有限),我还倾向于使用“文档”文件夹 - 以及每个用户的子文件夹。 每个文件名应包含日期以防止冲突。 随着时间的推移,您将不得不通过管理方式或用户界面来处理删除旧的或过时的文件。 考虑为每个用户设置最大文件数或最大字节数。 您还需要处理已离职用户的文件。
Given your constraints (and assuming a limited number of total users) I'd also be inclined to go with a "documents" folder -- plus a subfolder for each user. Each file name should include the date to prevent collisions. Over time, you'll have to deal with getting rid of old or outdated files either administratively or with a UI for users. Consider setting a maximum number of files or maximum byte count for each user. You'll also want to handle the files of departed users.