ImNeos
ImNeos

Reputation: 567

Firebase Storage Rules, how to write in specific folder?

I have theses rules for now :

EDIT

    rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write;
    }
  }
}

But I only want to let people write in specific folder so I don't want to override all the pictures in case something goes wrong.

By exemple, I wanna do something like this

  "Belgium" : {
    "ChatPicture" : {
      "write" = "true",
      "read"= "true"
    }
  }

I don't really understand why it is so different from the realtime database rules. Thank you for your help

Upvotes: 5

Views: 2652

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317372

It's easy to specify a path in Storage security rules.

service firebase.storage {
  match /b/{bucket}/o {
    match /Belgium/ChatPicture/{allPaths=**} {
      allow read, write: if true;
    }
  }
}

Upvotes: 8

Related Questions