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
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.