yahms23
yahms23

Reputation: 336

FirebaseError: Bucket name not specified or invalid

I'm following a tutorial online for building a Social media app using Firebase on React.

What I'm finding very puzzling is I can access the storage bucket when I create a new user, setting the default sign-up image from one I've uploaded in the Firebase Storage (using the storage bucket endpoint).

However, when I try to send a POST request to update the image, using the same storage bucket endpoint, with a different image file, I get the error below:

FirebaseError: Bucket name not specified or invalid. Specify a valid bucket name via the storageBucket option when initializing the app, or specify the bucket name explicitly when calling the getBucket() method.
 at new FirebaseError (/Users/yousef/codeclan_work/run_dat/functions/node_modules/firebase-admin/lib/utils/error.js:42:28)
 at Storage.bucket (/Users/yousef/codeclan_work/run_dat/functions/node_modules/firebase-admin/lib/storage/storage.js:109:15)
 at Busboy.<anonymous> (/Users/yousef/codeclan_work/run_dat/functions/handlers/users.js:111:25)
 at Busboy.emit (events.js:209:13)
 at Busboy.emit (/Users/yousef/codeclan_work/run_dat/functions/node_modules/busboy/lib/main.js:37:33)
 at /Users/yousef/codeclan_work/run_dat/functions/node_modules/busboy/lib/types/multipart.js:52:13
 at processTicksAndRejections (internal/process/task_queues.js:75:11) {
>    errorInfo: {
>      code: 'storage/invalid-argument',
>      message: 'Bucket name not specified or invalid. Specify a valid bucket name via the storageBucket option when initializing the app, or specify the bucket name explicitly when calling the getBucket() method.'

I'm accessing both buckets via this:

https://firebasestorage.googleapis.com/v0/b/${config.storageBucket}/o/${ImgFile}?alt=media

I've tried manually typing in the storage bucket rather than passing in the values, and still get the same error.

Upvotes: 7

Views: 8747

Answers (2)

Sonu
Sonu

Reputation: 187

I ran into the same issue, for me specifying a default bucket while initializing the admin worked. //admin.js

const admin = require("firebase-admin");
admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    storageBucket: "<BUCKET_NAME>.appspot.com"
});

Upvotes: 17

Frank van Puffelen
Frank van Puffelen

Reputation: 599051

firebaser here

If this is a project you created in the past 24 hours, it might be related to this incident: https://status.firebase.google.com/incident/Storage/20001.

There were issues creating buckets for new projects, so I'd recommend opening the Storage panel in the Firebase console, or creating a fresh project.

If the problem persists, reach out to Firebase support for personalized help in troubleshooting.

Upvotes: 3

Related Questions