How to resolve the error ( code: "Storage/unauthorized" ) within firebase

Asked

Viewed 117 times

-1

I’m here with an angle panel for maintenance. All I need to do is upload a pdf file to the server, and return the download url of this same file. But I’m bumping into this mistake and I can’t move. I have researched several places, tried several solutions and none solved my problem. Could anyone tell me how I can fix this error?

My piece of code is:

enviarNotaFiscal() {
console.log('upando a nota fiscal');
const name = this.notaFiscal.name;
const ref = this.afs.ref(`notasfiscais/nota.pdf`);
const task = ref.put(this.notaFiscal);
task.percentageChanges().subscribe(data => {
  console.log(data);
});
task.then(data => {
  data.ref.getDownloadURL().then(result => {
    console.log(result);
  })
    .catch((error) => {
      console.error(error);
    });
})
  .catch((error) => {
    console.error(error);
  });

}

The error that returns me on the console is:

inserir a descrição da imagem aqui

The most interesting that this code is the same that I usually use in my projects, therefore I believe that the problem is in the configuration of the firebase project or something, however as I did not start this project, I do not know answer.

Any help will be welcome.

1 answer

0

a silly mistake on my part. The Storage paths in the security rules and in the project settings were different, I made the correction and everything occurred as expected. Problem solved.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.