Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
Firebase Storage Security Rules request being denied

I'm trying to build a basic social media site with profile photos that any user can read, but each user can edit only their own photo. I wrote it after reviewing the documentation here https://firebase.google.com/docs/storage/security/rules-conditions

and when I use the simulator on the storage settings with a test authenticated user I get a success

Here is a photo of the successful test read: https://i.stack.imgur.com/ZCF5L.png

But I also have tried running this on my deployed app and each request no matter read or write, authenticated or not, I keep getting my request declined

failed storage request from deployed app

These are my security rules:

service cloud.firestore {
  match /b/{bucket}/o {
    match /internal/profilePhoto/{imageId} {
         allow read: if request.auth != null;
     allow write: if request.auth.uid == imageId;
        }
  }
}

and here is my code with the address I'm requesting from

async function upload(file, currentUser, setLoading) {
   const fileRef = ref(storage, 'internal/profilePhoto/'+currentUser.uid);

   setLoading(true);

   console.log(currentUser.uid)
   const snapshot = await uploadBytes(fileRef, file);

  const photoURL = await getDownloadURL(fileRef);

   updateProfile(currentUser, {photoURL});

   setLoading(false);
   alert("Uploaded file!");
}

Any guidance would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I figured it out. I opened another app with the default testing storage settings and my code let me upload to that database. I looked back at my FIREBASE STORAGE security settings and noticed that that first line said

service cloud.fireststore {

That was my problem. I accidentally copied in a rule setting for cloud firestore which left my storage database without any security rules which I assume made the default no access. If you want to set a rule setting for firebase storage than that rule needs to be

service firebase.storage {

I hope this saves at least one person a few hours of head banging.

The full rule setting I'm using for testing is

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**}{
     allow read, write: if true;
    }
  }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!