Jso*_*son 2 python google-cloud-platform
我正在尝试在 Google Cloud Platform 上遵循Google 的这个示例,但它没有按预期工作,当我使用 get_blob 方法时,我得到“ None ”。
(我仔细检查了文件的路径和名称,它是正确的)。
from google.cloud import storage
if __name__ == '__main__':
storage_client = storage.Client.from_service_account_json('Motion Detector-11eeeea.json')
bucket = storage_client.get_bucket('motion-detector-11.appspot.com')
print ('bucket',bucket) //output: bucket, motion-detector-11.appspot.com
zebraBlob = bucket.get_blob('/home/pi/Pictures/testimg.jpg')
print (zebraBlob) //output: None
Run Code Online (Sandbox Code Playgroud)
运行 Python 2.7.9。
请告知如何解决此问题。
对于所有正在努力遵循 Google 代码示例的人,请注意我为使其工作所做的一些调整:
1) 确保相关路径正确,我的 test.py 位于 pi/home 所以路径应该是:
//图片//testimg.jpg
代替
'/home/pi/Pictures/testimg.jpg'
我故意使用两个斜杠,因为 /t 是制表符。
2)我将bucket.get_blob改为bucket.blob
就是这样,我运行了脚本,打开了谷歌云,文件就在那里。
| 归档时间: |
|
| 查看次数: |
2139 次 |
| 最近记录: |