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

编程入门 行业动态 更新时间:2024-10-28 14:27:53
本文介绍了使用Python将图片文件上传到Firebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I have tried so much but I'm unable to figure out why this the returned object imageBlob in my code is NoneType ? Please some body help me

我的代码是

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('auburnfirebase.firebaseio', None) imageUrl = "imageurlkalyan" firebase.delete('/image',None) result = firebase.post('/image',imageUrl) cred = credentials.Certificate('storageServiceAuburn.json') firebase_admin.initialize_app(cred, { 'storageBucket': 'auburnfirebase.appspot' }) bucket = storage.bucket() print bucket img = cv2.imread('photo.png') #cv2.imshow('image',img) imageBlob = bucket.get_blob('C:/Python27/photo.png') print imageBlob

预先感谢

推荐答案

是的!我明白了

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

仅通过更改大量有效代码即可

only by changing this much of code it worked

更多推荐

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

本文发布于:2023-10-26 10:17:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1529844.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件上传   图片   Python   Firebase

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!