2
votes

Just a quick question regarding how to implement multiple Firebase Storage Security rules.

In fact I would like to limit the size of files that could be uploaded, but keeping my Auth Rules.

I have been reading this previous post which gave me a hint on how to limit the upload size per file, but I'm still struggling to implement "match /files/{fileName}" somewhere with the Auth Rules.

After multiple tries, this is my last iteration of it before writing this post:

service firebase.storage {
match /b/xxxxxxxx-xxx.appspot.com/o {
  match /{allPaths=**}{
    allow read: if request.auth != null;
    allow write: if request.auth != null && request.resource.size < 1 * 1024 * 1024;
  }
 }
}

Of course, I did read the official Documentation, but it seems like I still can't get it right.

1
What is failing? You are able to upload files larger than 1MB?Bob Snyder
No it is working, I cannot upload files bigger than 1MB but reading this post (stackoverflow.com/questions/38395790/…) I'm trying to also write the "match /files/{fileName}" partAndy Strife
It's not clear what your question is. You say the rules you posted behave as expected. If you need help with the "match" part, describe the path(s) you want to match and explain what problem you are having.Bob Snyder

1 Answers

0
votes

You would just put the match path in the match statement. Is that the simple question you were asking? Here it is below.

service firebase.storage {
  match /b/{bucket}/o {
    match /files/{fileName}{
      allow read: if request.auth != null;
      allow write: if request.auth != null && request.resource.size < 1 * 1024 * 1024;
  }
 }
}