limit number of children with storage rules

 ̄綄美尐妖づ 提交于 2019-12-24 19:13:36

问题


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;
    }
  }
}

thanks in advance


回答1:


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

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.



来源:https://stackoverflow.com/questions/45339006/limit-number-of-children-with-storage-rules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!