1
votes

I need to set firebase storage rules so unauthenticated users can upload a file but can't read a file.

So far I have:

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

Is this the correct way to do this?

1

1 Answers

1
votes

This rule will help you to read only if user is authenticated else it won't allow. For more details you can read docs

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read: if request.auth != null;
      allow write: if true;
    }
  }
}