简体   繁体   English

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

[英]Upload Image file to Firebase in Python

I have tried so much but I'm unable to figure out why this the returned object imageBlob in my code is NoneType ? 我已经做了很多尝试,但是我无法弄清楚为什么我的代码中返回的对象imageBlob是NoneType? Please some body help me 请一些身体帮助我

My Code is 我的代码是

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

Thanks in advance 提前致谢

Yes! 是! i got that 我明白了

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

only by changing this much of code it worked 仅通过更改大量的代码就可以了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM