【发布时间】: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