1

I started out with an issue simply displaying storage contents. The error message was the same Code 400 "Permission denied. Could not access bucket bucket. Please enable Firebase Storage for your bucket by visiting the Storage tab in the Firebase Console and ensure that you have sufficient permission to properly provision resources."

But the changes I made based on This stackoverflow question made the issue worse, now my upload form is giving the same error now and blocks file uploads, even after rolling back all the changes. I tried creating a brand new project on Firebase, but that has the same error. I also tried to set my bucket permissions to

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read;
      allow write;
    }
  }
}

since I thought that it could be a rights issue, but I get the same error.

Phix
  • 9,364
  • 4
  • 35
  • 62
Rostasan
  • 57
  • 9
  • Can you also post the code you use to upload to GCS? – Hiranya Jayathilaka Mar 04 '19 at 22:57
  • Sure, I'll recreate the app on stackblitz and link it in once I have it up and running. – Rostasan Mar 05 '19 at 01:44
  • 1
    Do not link your code. Put your code in your question. Make sure all information necessary to reproduce the problem is included in the question itself: https://stackoverflow.com/help/mcve – John Hanley Mar 05 '19 at 02:33
  • 1
    Have you checked if your project falls in any of the known issues for storage in Firebase? https://firebase.google.com/support/faq/#storage-buckets – scobr Mar 05 '19 at 16:53
  • Actually I was working on reproducing the issue in a stackblitz and I noticed the error "Permission denied. could not access bucket **bucket**." Bucket of course is not my storage bucket. So now I think the issue is with the code. I'm going to go over the service again and if I can't get it to work I'll post a stackblitz. This is frustrating because I thought I undid all of the troubleshooting changes. – Rostasan Mar 05 '19 at 20:58

1 Answers1

1

I'm not sure what I was trying to do when I added this bit of code, but I had added

 { provide: StorageBucket, useValue: 'bucket' }

To my providers: on my app.module. I think it was a place holder for something and I forgot to remove it before committing the project.

This led me down and interesting troubleshooting path that finally led me to doing breakpoints and console logs until I found the issue.

   const task = this.storage.upload(filePath, file);

I did a console log of task, which gave me a location, that's where I found

 bucket: bucket

I then added the same console.log to a working project that showed

 bucket: whatever.appspot.com 

and I knew I made a mistake somewhere. I just happened across the entry in the app.module.ts file while trying to recreate the issue in stackblitz. The error is resolved.

Rostasan
  • 57
  • 9
  • I tried the first part of the solution, removing `{provide: StorageBucket, useValue: 'my-bucket-name'}` from my app.module and it worked – Paco Zevallos Mar 08 '19 at 19:47
  • You know Paco I have no idea why I added that bit of code. If I track down what it was I'll also note it. Do you happen to know how you added it? I don't think that just generates in Angular-cli on its own. – Rostasan Mar 09 '19 at 04:38