如何给用户设置文件存储限制?
我现在正在使用 Rails 开发一个 Web 应用程序,想看看是否有人知道跟踪文件存储限制的好方法?我们希望为用户提供特定数量的空间供他们上传文件,并且我们使用回形针在 Amazon S3 上进行存储。有什么想法吗?谢谢
I'm working on a web application right now using Rails and wanted to see if anyone knew of a good way to keep track of file storage limits? We want to give users a specific amount of room that they can use to upload files and we are using paperclip for storage on Amazon S3. Any thoughts? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以与回形针一起使用的可选列之一是 OBJECT_file_size ,您可以对其进行总结,就像
至于实际施加的上限一样,我建议对任何文件模型创建自定义验证,以便您可以将错误和问题传递回来给客户。
One of the optional columns you can use with paperclip is the OBJECT_file_size which you can sum up like
As to the actually imposing the cap, I'd recommend creating a custom validation on whatever the file model is so that you can pass errors and issues back to the client.
回形针存储文件大小。
因此,您可以为一个用户执行以下操作:
然后您将获得每个用户文档的总大小。
然后,您可以添加最大大小限制,如果用户达到该大小,则不验证文档的上传。
Paperclip stores the file size.
So you could just, for one user, do something like :
You'll then have the total size of every user's documents.
You can then add a max size limit and not validate the document's upload if the user has reached that size.