我在Linux上使用Python2.7.9,在Google-Cloud Server SDK上使用谷歌的example。我的目标是上传一张图片到Google Cloud Platform,但是我得到了下面的错误。
File "/home/pi/test.py", line 15, in <module>
zebraBlob.upload_from_filename(filename='/home/pi/Pictures/testimg.jpg')
AttributeError: 'NoneType' object has no attribute
'upload_from_filename'
代码:
from firebase import firebase
from google.cloud import storage
import os
firebase = firebase.FirebaseApplication('https://motion-detector-234.firebaseio.com', None)
storage_client = storage.Client.from_service_account_json('Motion Detector-8gf5445fgeeea.json')
bucket = storage_client.get_bucket('motion-detector-210fds717.appspot.com')
print ('bucket', bucket) // output: bucket, motion-detector-210717.appspot.com
zebraBlob = bucket.get_blob('testimg.jpg')
print(zebraBlob) // output: None
zebraBlob.upload_from_filename(filename='/home/pi/Pictures/testimg.jpg')
如何解决呢?
发布于 2018-12-13 07:02:20
要使其工作,只需编写zebraBlob = bucket.blob('testimg.jpg')
而不是zebraBlob = bucket.get_blob('testimg.jpg')
https://stackoverflow.com/questions/51439904
复制相似问题