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')
我遇到错误:
buck=storage.storage()
AttributeError: 'function' object has no attribute 'storage'
答案 0 :(得分:0)
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
答案 1 :(得分:0)
# 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')