使用Python将图像文件上传到Firebase

时间:2018-03-28 05:30:02

标签: python firebase firebase-storage

我已经尝试过这么多,但我无法弄清楚为什么我的代码中返回的对象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

提前致谢

1 个答案:

答案 0 :(得分:0)

是的!我明白了

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

只能通过改变它的大部分代码来实现