尝试使用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)