Google Cloud Storage Python客户端
项目描述
GCS-Client
Google Cloud Storage Python客户端
Apache 2.0许可证
想法是创建一个具有类似功能的客户端,类似于 Google的appengine-gcs-client,但旨在用于在Google AppEngine之外运行的应用程序。
Cloud Storage文档可以在 Google 找到
功能
目前只提供基本功能
创建存储桶
删除存储桶
列出项目中的存储桶
获取项目的默认存储桶
获取存储桶属性
列出存储桶中的对象
获取对象的属性
删除对象
读取对象内容
写入对象
可配置的带截断指数退避的重试
安装
要安装,只需运行
$ pip install --upgrade gcs-client
用法示例
要在项目中使用gcs-client,您需要有权访问目标Google Cloud Storage的凭据。
凭据由项目API管理器的 Google开发者控制台 中的 凭据部分 生成。建议的凭据文件是JSON。
一旦您有了凭据,您就可以开始使用gcs_client来访问您的项目
import gcs_client
credentials = gcs_client.Credentials('private_key.json')
project = gcs_client.Project('project_name', credentials)
# Print buckets in the project
buckets = project.list()
print 'Buckets:\n\t-', '\n\t- '.join(map(str, buckets))
# Print some information from first bucket
bucket = buckets[0]
print 'Bucket %s is located in %s with storage class %s' % (bucket, bucket.location,
bucket.storageClass)
# List the objects in the bucket
objects = bucket.list()
if not objects:
print 'There are no objects, creating one'
filename = '/tmp/my_file.txt'
with bucket.open(filename, 'w') as f:
f.write('this is a test file\n' * 100)
objects = [gcs_client.Object(bucket.name, filename, credentials=credentials)]
if objects:
print '\t', '\n\t'.join(map(lambda o: o.name + ' has %s bytes' % o.size, objects))
# Read the contents from the first file
with objects[0].open() as obj:
print 'Contents of file %s are:\n' % obj.name, obj.read()
else:
print 'There are no objects, nothing to do'
更多示例可以在文档的使用部分找到。
问题报告
如果您在gcs-client中发现问题,以下是报告问题的方法
首选方法是向GitHub提交一个bug
前往项目的GitHub问题跟踪器
使用页面顶部的搜索字段搜索现有问题
提交一个新问题,包含关于问题的信息
感谢您帮助使gcs-client变得更好
如果您没有GitHub账户并且不想创建一个,您可以给我发电子邮件。
历史
0.2.2 (2016-11-26)
修复#1 - 媒体上传不工作
0.2.1 (2016-03-26)
修复需求问题
0.2.0 (2015-11-25)
添加使用Prefix对象的列表分隔符支持
从google-api-python-client中移除依赖
在AttributeError上返回描述性错误消息
0.1.4 (2015-11-16)
没有更改,版本升级到pypi重新加载
0.1.3 (2015-11-16)
读取对象将返回字节数据,而不是bytearray。
读取对象的特定版本。
可以在Bucket的open和Object init上指定chunksize。
添加到bucket和project的exists方法。
修复需要编码的文件名打开问题。
0.1.2 (2015-11-10)
修复seek方法。
0.1.1 (2015-11-09)
修复Pypi包。
0.1.0 (2015-11-09)
PyPI上的首次发布。
项目详情
下载文件
下载您平台上的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
构建分布
gcs-client-0.2.2.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a8657176ce92b0e0cf6fde738e94b6bc71eafc99f7711723c306eeb952d6bd55 |
|
MD5 | 3156d6e5c192551ba664a47803a9b3dd |
|
BLAKE2b-256 | 789a226e8345dfbedc08fecab23a9132e71deb33a38eae2f2f39f5584c28c945 |
gcs_client-0.2.2-py2.py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 56067991305ff61d6aff2e1d663da361d334670d8c2255b715507fbeb902ce11 |
|
MD5 | ad63ab84b18c1318edd5a33580b54d29 |
|
BLAKE2b-256 | f1a9c5ad5745b0146aada03f13313bbf34735f26df8308973a2348b7772f31ec |