Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda