question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Urgent: Firebase file upload not working

See original GitHub issue

As showed in npm/firebase, Server side Firebase npm module is not support. Instead, you can use the gcloud Node.js client . image

/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////

var gcloud = require('gcloud');

var gcs = gcloud.storage({
  projectId: 'firebase-project',
  keyFilename: 'firebase-key.json'
});

var bucket = gcs.bucket('petertest-25efd.appspot.com');

bucket.upload('/photos/zoo/zebra.jpg', function(err, file) {
  if (!err) {
    // "zebra.jpg" is now in your bucket. 
  }
});

/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////

This is the error:

{ [ApiError: Forbidden]
  code: 403,
  errors: [ { domain: 'global', reason: 'forbidden', message: 'Forbidden' } ],
  response: undefined,
  message: 'Forbidden' }

image

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
asciimikecommented, Jul 25, 2016

Comment 9 above shows the bucket permissions, and your service account should be added as an owner/editor of the projectid.appspot.com bucket (depending on how you configured the service account it may or may not be that way). You’ll need it on both the default bucket ACLs as well as the default object ACLs.

The docs on service accounts for GCS buckets are here: https://cloud.google.com/storage/docs/authentication#service_accounts but might not be terribly helpful.

1reaction
jgeewaxcommented, Jun 20, 2016

Also - does the service account inside firebase-key.json have access to the bucket you’re trying to access?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upload files with Cloud Storage on Web - Firebase
Cloud Storage for Firebase allows you to quickly and easily upload files to a Cloud Storage bucket provided and managed by Firebase.
Read more >
Upload Files to Firebase Storage - Tutorial
You should get a 'Complete' success output. Go to your Firebase Storage console (refresh it) and see your file is there now. If...
Read more >
Trying to upload files to firebase storage but its not working. ...
Trying to upload files to firebase storage but its not working. Error object is empty, how do I figure out what's wrong?
Read more >
Upload images to Firebase Cloud Storage — WorkManager
A step-by-step guide to uploading images from a Worker instead of using a Service . The use-case. Uploading images to a remote server...
Read more >
Upload images to Firebase Cloud Storage — WorkManager
Authorization is necessary for uploading to and downloading files from Cloud Storage . Set the sign-in method to Anonymous in the Firebase console....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found