【问题标题】:Upload Image file to Firebase in Python在 Python 中将图像文件上传到 Firebase
【发布时间】:2018-03-28 05:30:02
【问题描述】:

我已经尝试了很多,但我无法弄清楚为什么我的代码中返回的对象 imageBlob 是 NoneType ? 请一些人帮助我

我的代码是

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.get_blob('C:/Python27/photo.png')
print imageBlob

提前致谢

【问题讨论】:

  • 这里我正在尝试将图像文件上传到 Firebase 存储

标签: python firebase firebase-storage


【解决方案1】:

是的!我明白了

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

只有修改这么多代码才有效

【讨论】:

    猜你喜欢
    • 2017-07-28
    • 1970-01-01
    • 2021-07-03
    • 1970-01-01
    • 1970-01-01
    • 2019-03-26
    • 2020-04-30
    • 2017-07-02
    • 1970-01-01
    相关资源
    最近更新 更多