Urgent: Firebase file upload not working
See original GitHub issueAs showed in npm/firebase, Server side Firebase npm module is not support. Instead, you can use the gcloud Node.js client .
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
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' }
Issue Analytics
- State:
- Created 7 years ago
- Comments:21 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
Also - does the service account inside
firebase-key.json
have access to the bucket you’re trying to access?