【问题标题】:Firebase storage in free plan: The project to be billed is associated with an absent billing account免费计划中的 Firebase 存储:要计费的项目与缺席的计费帐户相关联
【发布时间】:2020-12-16 09:17:16
【问题描述】:

我正在尝试将图片上传到我的 Firebase 存储帐户,但每当我运行代码时,我都会遇到 403 HTTP 错误:“要计费的项目与缺席的计费帐户相关联”。 注意我使用的是免费订阅(spark plan),所以这个问题和不相似:Google Cloud Storage bucket throws error "The project to be billed is associated with a closed billing account."

一个更详细的错误:

"error": {
    "code": 403,
    "message": "The project to be billed is associated with an absent billing account.",
    "errors": [
      {
        "message": "The project to be billed is associated with an absent billing account.",
        "domain": "global",
        "reason": "accountDisabled",
        "locationType": "header",
        "location": "Authorization"
      }
    ]
  }

这是我的 Python 代码:

import firebase_admin
from firebase_admin import credentials, storage
import os


cred = credentials.Certificate(os.getenv("FIREBASE_CREDS"))
firebase_admin.initialize_app(cred)
bucket = storage.bucket('profile_pictures')
blob = bucket.blob("test_image.jpg")
blob.upload_from_string(test_image_path)

问题是来自我的 python 代码,还是来自我需要在 firebase 中修复的某些设置? 使用 Spark 计划,我们应该有一些免费存储空间(目前,我没有存储任何东西......)

【问题讨论】:

  • 您确定profile_pictures 是存储桶名称而不是“文件夹”名称(您可以在 Firebase 控制台中看到文件夹,但它们不是真正的文件夹,只是从斜杠分隔的文件名生成的)?您能否展示您的 Firebase Cloud Storage 控制台的图片?
  • 绝对是文件夹名!我没有看到我可以给出的任何其他值?
  • 好的,这就是问题所在......在存储桶中,我应该提供我的应用程序网址。然后在 bucket.blob 中:“folder_name/picture_name”。如果可以的话,我认为 HTTP 错误消息具有误导性!不过非常感谢!!

标签: python firebase firebase-storage


【解决方案1】:

问题在于您混淆了“bucket”和“filename”。

您需要将以下值传递给storage.bucket() 方法:gs://[your-project-id].appspot.com

您需要将完整的文件名传递给bucket.blob(),包括“文件夹”部分。


请注意,您可以在 Firebase 控制台中看到文件夹,但实际上,它们并不是真正的文件夹:它们只是由斜线分隔的文件名生成,以便在 Firebase 控制台中导航。

【讨论】:

    猜你喜欢
    • 2019-09-23
    • 2019-05-18
    • 1970-01-01
    • 2022-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-12
    相关资源
    最近更新 更多