我正在嘗試將圖片上傳到我的 Firebase 存儲帳戶,但每當運行代碼時,都會出現 403 HTTP 錯誤:“要計費的項目與不存在的計費帳戶關聯”。更詳細的錯誤:"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_adminfrom firebase_admin import credentials, storageimport oscred = 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 計劃,我們應該有一些免費存儲空間(目前,我沒有存儲任何東西......)
1 回答

小怪獸愛吃肉
TA貢獻1852條經驗 獲得超1個贊
問題來自于您混淆了“存儲桶”和“文件名”。
您需要將以下值傳遞給該storage.bucket()
方法:gs://[your-project-id].appspot.com
和
您需要將完整文件名傳遞給bucket.blob()
,包括“文件夾”部分。
請注意,您可以在 Firebase 控制臺中看到文件夾,但實際上它們不是真正的文件夾:它們只是根據斜杠分隔的文件名生成的,以便于在 Firebase 控制臺中導航。
添加回答
舉報
0/150
提交
取消