简体   繁体   中英

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

# 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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