Search code examples
firebasegoogle-cloud-platformfirebase-storagefirebase-security

i am getting Permission denied error when i upload image on firebase


I am working on Firebase image upload. but facing an error in my rules of storage.

       rules_version = '2';
       service firebase.storage {
      match /b/savephoto-a1cc3.appspot.com/o {
        match /{allPaths=**} {
  // Allow access by all users
  allow read, write;
    }
}
  }

Solution

  • Since you say that you have already implemented Firebase Authentication, then the following rules will do the trick:

    service firebase.storage {
      match /b/{bucket}/o {
        match /{files} {
          allow read, write: if request.auth != null;
        }
      }
    }
    

    If you want to have data validation as well, please check the official documentation: