python - 我正在尝试将图像上传到 firebase 但出现错误。我正在使用 python 3.6.1

标签 python

import firebase_admin
from firebase_admin import credentials,firestore
from firebase_admin import storage
from google.cloud import storage
from google.cloud.storage import client

cred = credentials.Certificate('a.json')
firebase_admin.initialize_app(cred, {
    'storageBucket': 'gs://test-e8fcf.appspot.com/'
})
buck=storage.storage()

blob = buck.blob('F:/b.PNG')
blob.upload_from_filename(filename='F:/b.PNG')

我收到错误:

    buck=storage.storage()
AttributeError: 'function' object has no attribute 'storage'

最佳答案

import firebase
from google.cloud import storage
from google.cloud.storage import client
import cv2

import firebase_admin
from firebase_admin import credentials
from firebase_admin import storage

currentImage = None
firebase = firebase.FirebaseApplication('https://auburnfirebase.firebaseio.com', None)

imageUrl = "imageurlkalyan.com"
firebase.delete('/image',None)
result = firebase.post('/image',imageUrl)

cred = credentials.Certificate('storageServiceAuburn.json')
firebase_admin.initialize_app(cred, {
    'storageBucket': 'auburnfirebase.appspot.com'
})

bucket = storage.bucket()
print bucket

img = cv2.imread('photo.png')
#cv2.imshow('image',img)

imageBlob = bucket.blob(os.path.basename('C:/Python27/photo.png'))
print imageBlob

Upload Image file to Firebase in Python

关于python - 我正在尝试将图像上传到 firebase 但出现错误。我正在使用 python 3.6.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55872803/

相关文章:

python - 使用 google app engine 作为 smtp 服务器

python - 在对象实例上使用装饰器(或其他一些模式)来生成类

python - 修复无效的 JSON 八进制转义

python - 如果 WTForms 被定义为验证字段,它如何知道使用 validate_<field name>?

python - bash 中的标准输出被一行代码阻塞

python - 使用 groupby 创建新数据框

Python 多处理模块 freeze_support() line can be omitted error Windows

c++ - 在 Python 中公开 C++ 全局变量

python - 仅保存 pandas df 中的非空条目值和列号,每行仅保存一个非空值

python - 在 Python 脚本控制的 GDB 中添加断点命令列表