简体   繁体   English

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

[英]i am trying to upload an image to firebase but i am getting an error. i am using python 3.6.1

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')

i am getting an error: 我收到一个错误:

    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

# Import gcloud
from google.cloud import storage

# Enable Storage
client = storage.Client()

# Reference an existing bucket.
bucket = client.get_bucket('projectid.appspot.com')

# Upload a local file to a new file to be created in your bucket.
zebraBlob = bucket.get_blob('zebra.jpg')
zebraBlob.upload_from_filename(filename='/photos/zoo/zebra.jpg')

How to upload images to Firebase from Raspberry Pi? 如何从Raspberry Pi将图像上传到Firebase?

暂无
暂无

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

相关问题 我在Python中使用基本脚本但是出现以下错误。 这是什么意思? - I am using a basic script in Python but am getting the following error. What does it mean? 我使用python 3.6.1从json读取twitter数据集的代码出错 - I am getting error with my codes to read twitter data sets from json using python 3.6.1 我正在尝试将此图像保存在一个文件夹中,但它显示此错误。 我在这里做错了什么? - I am trying to save this image in a folder but it is showing this error. What am I doing wrong here? 我正在尝试使用 Python 从 Excel 检索内容。 我收到投资未定义错误 - I am trying to retrieve the content from an Excel using Python. I am getting Investment undefined error 我正在尝试使用 python 将 mp4 文件转换为文本,但出现此错误 - I am trying to convert mp4 file into text using python but i am getting this error 我收到“错误:安装 pocketsphinx 时 python 3.6.1 需要 Microsoft Visual C++ 14.0 - I am getting "error: Microsoft Visual C++ 14.0 is required on python 3.6.1 while installing pocketsphinx 试图点击按钮给我一个错误。 我正在使用 repl.it python 环境 - Trying to click on button gives me an error. I am using repl.it python environment 我在Mac Mojave上,正尝试将python乌龟游戏转换为exe应用,但遇到意外错误 - I am on Mac Mojave and am trying to convert a python turtle game into an exe app, but am getting an unexpected error 尝试替换时出现类型错误 - I am getting a type error when I am trying to replace 试图让我的 python 程序运行,但我不断收到变量赋值错误。 关于我做错了什么的任何想法? - Trying to get my python program to run but I keep getting a variable assignment error. Any ideas as to what I am doing wrong?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM