在Firebase中为云存储的最大文件夹大小限制添加规则 [英] Add rule for maximum folder size limit for cloud storage in firebase

查看:164
本文介绍了在Firebase中为云存储的最大文件夹大小限制添加规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何添加规则来限制用户可以消耗的最大存储空间大小?当前的 request.resource.size 限制了用户可以上传的文件的大小,而不是用户上传到的文件夹/存储区大小。我希望在用户可以上传的所有内容上放置一个50 MB的限制。

更新:

为了重新构建这个问题,想象一下,用户已经上传了5张大小为10MB的图像,这使得它总共为50MB。现在我想限制用户上传任何更多的文件作为最大桶大小(在我的情况下:50MB)已经达到。可能有两个20 MB的文件和10 MB的文件之一,但50 MB的整体上限必须得到尊重。如何为此添加规则?



更新2:



是不是在当前的实现中,经过身份验证的用户可以继续上传无限数量的数据,并以每个文件大小为10 MB为限,这是以托管Firebase服务的用户为代价的(假设您在托管时按照定价模式付款)?$ b $你可以通过检查文件大小直接在客户端做到这一点。看看这个文件 api具有方法大小的方法。你可以检查用户是否超过了文件限制,那么你可以限制他上传。


How can I add a rule to limit the maximum storage space size a user can consume? The current request.resource.size limits the size of a file a user can upload but not the folder/bucket size the user is uploading to. I wish to place a limit say 50 MB over all the content the user can upload.

Update:

To reframe the question, imagine the user has already uploaded 5 images of size 10MB each which makes it 50 MB altogether. Now I want to restrict the user from uploading any more files as the maximum bucket size (in my case: 50MB) is already reached. There could have been 2 files of 20 MB each and one of 10 MB, but the overall cap of 50 MB has to be respected. How do I add a rule for that?

Update 2:

Is it that in the current implementation, an authenticated user can keep on uploading an infinite amount of data say capped at 10 MB file size each at the expense of the user hosting the Firebase service (Assuming a pay as you go pricing model while hosting)?

解决方案

You can directly do that on the client side by checking the file size.Check out this File api which has method size method.You can a check if the user has exceeded the file limit, then you can restrict him from uploading.

这篇关于在Firebase中为云存储的最大文件夹大小限制添加规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆