小编Rus*_*mov的帖子

Google云端存储客户端

我用GCS做了第一步

首先,我在我的项目中创建了服务帐户,并在json中获得了密钥文件

接下来,我试着像这个样本一样编写脚本

但...

from gcloud import storage

client = storage.Client.from_service_account_json('/path/to/keyfile.json')

bucket = client.get_bucket('enggeo')
# Then do other things...
blob = bucket.get_blob('/ETicket.pdf')
print blob.download_as_string()
blob2 = bucket.blob('/wtt.txt')
blob2.upload_from_filename(filename='/home/test2/.www/test')
Run Code Online (Sandbox Code Playgroud)

并得到错误

File "tt.py", line 3, in <module>
client = storage.Client.from_service_account_json('/path/to/keyfile.json')  # TODO: rel paths
File "/home/test2/lib/python2.7/site-packages/gcloud/client.py", line 64, in from_service_account_json
return cls(*args, **kwargs)
File "/home/test2/lib/python2.7/site-packages/gcloud/storage/client.py", line 53, in __init__
http=http)
File "/home/test2/lib/python2.7/site-packages/gcloud/client.py", line 181, in __init__
_ClientProjectMixin.__init__(self, project=project)
File "/home/test2/lib/python2.7/site-packages/gcloud/client.py", line 146, in __init__
raise ValueError('Project was not passed and …
Run Code Online (Sandbox Code Playgroud)

google-cloud-storage

2
推荐指数
1
解决办法
3434
查看次数

标签 统计

google-cloud-storage ×1