文件存储+权限:mongodb 与文件系统方法
我正在开发的java web应用程序允许用户将文件(图片和文档)上传到他们的个人资料并定义这些文件的访问规则(定义哪些其他用户能够查看/下载该文件)。访问控制/权限系统是定制的,规则与用户的个人资料和实际文件条目一起存储在 mongoDB 中。
知道我需要分布式且容错的应用程序和存储,我需要弄清楚哪种是文件存储的最佳策略。
我是否应该将 mongoDB 内的文件存储在包含描述和访问规则的文件文档所在的文件集合中?
或者我应该将文件存储在服务器的文件系统中并将路径保留在 mongoDB 文档中?通过文件系统方法,我仍然能够强制执行用户定义的访问权限以及如何执行? 最后,在文件系统方法中,如何跨服务器分发文件?我应该为此使用专用服务器还是可以将文件存储在 webapp 服务器或 mongodb 服务器上?
非常感谢您的所有见解!任何帮助或反馈表示赞赏。
亚历克斯
The java web app I'm developing allows users to upload files (pictures and documents) to their profiles and define access rules for those files (define which of the other users are able to view / download the file). The access control / permission system is custom made and rules are stored in mongoDB alongside the user's profile and the actual file entry.
Knowing that I need the application and storage to be distributed and fault-tolerant I need to figure out which is the best strategy for file storage.
Should I store the files inside mongoDB in the files collection where the file document containing description and access rules are located ?
Or should I store the files inside the server's file system and keep the path in the mongoDB document? With the filesystem approach will I still be able to enforce the user defined access permissions and how?
Finally in the filesystem approach how do I distribute files accross servers? Should I use dedicated servers for this or can I store the files on the webapp servers or mongodb servers ?
Thanks a lot for all your insights! Any help or feedback appreciated.
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几种替代方案:
就您而言,听起来最后一个选项可能是最好的,有相当多的用户从 FS 切换到 gridFS,并且它对他们来说非常有效。
需要记住的事情:
There are several alternatives:
In your case it sounds like last option may be best, there are quite a few users who switched from FS to gridFS and it worked very well for them.
Things to keep in mind: