通过Firebase 403将图片上传到Google存储空间时出错

时间:2019-03-30 20:44:12

标签: python-2.7 firebase google-cloud-storage firebase-storage

尝试使用Firebase库上载图像时遇到以下错误:google.api_core.exceptions.Forbidden: 403 POST https://www.googleapis.com/upload/storage/v1/b/images/o?uploadType=multipart: (u'Request failed with status code', 403, u'Expected one of', 200)

这是我的代码(python 2.7)

import firebase_admin
from firebase_admin import credentials, firestore, storage


cred = credentials.Certificate('./file.json')
firebase_admin.initialize_app(cred, {
    'storageBucket': 'bucket.appspot.com'
})
db = firestore.client()
bucket = storage.bucket('images')
old_filename = './file.jpg'
ext = '.jpg'
uuid = '1234'
blob = bucket.blob(uuid + ext)
blob.upload_from_filename(old_filename)

0 个答案:

没有答案