限制有存储规则的儿童数量 [英] limit number of children with storage rules

查看:43
本文介绍了限制有存储规则的儿童数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想限制用户最多上传4张图像. 存储规则可以限制特定节点中的子级数吗? 这是我的存储规则,没有孩子的限制.

I want to limit user to upload at most 4 images. storage rules can limit a number of children in specific node? this is my storage rules without children limitation.

    service firebase.storage {
  match /b/{bucket}/o {
    match /users/{uid}/{filename} {
      allow read, write: if request.auth.uid == uid;
    }
  }
}

预先感谢

推荐答案

简短的回答是否",根据

The short answer is no, there isn't a way to achieve this using storage security according to the documentation for storage security rules.

在评论中链接到Frank的相关问题有一个很好的答案.可以实现此目标的另一种方法是使用Cloud Functions for Firebase的实时数据库触发器.如果您已经将下载URL写入数据库,请使用Cloud Functions for Firebase计算子代数并对其进行限制,如

The related question Frank linked in the comments has a good answer. Another way you could make this happen is a Realtime Database trigger with Cloud Functions for Firebase. If you already write the download URLs to the database, use Cloud Functions for Firebase to count the number of children and limit them, as shown in this example.

这篇关于限制有存储规则的儿童数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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