FirebaseError: Bucket name not specified or invalid

FirebaseError: Bucket name not specified or invalid

我正在关注使用 Firebase on React 构建社交媒体应用程序的在线教程。

我发现非常令人费解的是,当我创建一个新用户时,我 可以 访问存储桶,设置我上传的默认注册图像Firebase 存储(使用存储桶端点)。

但是,当我尝试发送 POST 更新图像的请求时,使用相同的存储桶端点,但图像文件不同,我收到以下错误:

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.'

我正在通过此访问两个存储桶:

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

我尝试手动输入存储桶而不是传递值,但仍然出现相同的错误。

firebaser 在这里

如果这是您在过去 24 小时内创建的项目,则可能与此事件有关:https://status.firebase.google.com/incident/Storage/20001

为新项目创建存储桶时出现问题,因此我建议在 Firebase 控制台中打开“存储”面板,或创建一个新项目。

如果问题仍然存在,reach out to Firebase support 寻求个性化的故障排除帮助。

我 运行 遇到了同样的问题,对我来说,在初始化管理员时指定默认存储桶有效。 //admin.js

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