谷歌云存储python客户端

gcs-client的Python项目详细描述


地面军事系统客户端

https://img.shields.io/travis/Akrog/gcs-client.svghttps://img.shields.io/pypi/v/gcs-client.svghttps://img.shields.io/coveralls/Akrog/gcs-client/master.svgDocumentation Statushttps://img.shields.io/pypi/pyversions/gcs-client.svghttps://img.shields.io/:license-apache-blue.svg

谷歌云存储python客户端

其思想是创建一个具有类似于Google’s appengine-gcs-client的功能的客户机,但其目的是用于从外部运行的应用程序 谷歌的appengine。

云存储文档可以在Google

功能

目前只提供基本功能:

  • 创建存储桶
  • 删除存储桶
  • 列出项目中的存储桶
  • 获取项目的默认存储桶
  • 获取bucket属性
  • 列出bucket中的对象
  • 获取对象属性
  • 删除对象
  • 读取对象内容
  • 编写对象
  • 具有截断指数退避的可配置重试

安装

要安装,只需运行:

$ pip install --upgrade gcs-client

使用示例

要在项目中使用gcs客户端,您需要具有访问预期google云存储的凭据。

凭据在项目的api管理器的Credentials section中的Google Developers Console中生成。推荐的凭据文件是json。

一旦您有了凭据,就可以开始使用gcs_客户端访问您的项目:

importgcs_clientcredentials=gcs_client.Credentials('private_key.json')project=gcs_client.Project('project_name',credentials)# Print buckets in the projectbuckets=project.list()print'Buckets:\n\t-','\n\t- '.join(map(str,buckets))# Print some information from first bucketbucket=buckets[0]print'Bucket %s is located in %s with storage class %s'%(bucket,bucket.location,bucket.storageClass)# List the objects in the bucketobjects=bucket.list()ifnotobjects:print'There are no objects, creating one'filename='/tmp/my_file.txt'withbucket.open(filename,'w')asf:f.write('this is a test file\n'*100)objects=[gcs_client.Object(bucket.name,filename,credentials=credentials)]ifobjects:print'\t','\n\t'.join(map(lambdao:o.name+' has %s bytes'%o.size,objects))# Read the contents from the first filewithobjects[0].open()asobj:print'Contents of file %s are:\n'%obj.name,obj.read()else:print'There are no objects, nothing to do'

更多的例子可以在文档中的usage部分找到。

报告问题

如果您发现GCS客户端有问题,请使用以下方法报告问题:

  • 首选方法是在github上提交一个bug:
    1. 转到项目的issue tracker on GitHub
    2. 使用页面顶部的搜索字段< /LI>搜索现有问题
    3. 用有关问题的信息提交新问题
    4. 感谢您帮助改进GCS客户端
  • 如果您没有github帐户,并且不希望创建一个帐户,您可以 给我发邮件。

历史记录

0.2.2(2016-11-26)

  • 修复1-媒体上载无法工作

0.2.1(2016-03-26)

  • 解决需求问题

0.2.0(2015-11-25)

  • 在使用前缀对象的列表中添加对分隔符的支持
  • 从google api python客户端删除依赖项
  • 在attributeerror上返回描述性错误消息

0.1.4(2015-11-16)

  • 无更改,在pypi中重新加载版本bump

0.1.3(2015-11-16)

  • 读取对象将返回字节形式的数据,而不是字节数组。
  • 读取对象的特定版本。
  • 可以在bucket的open和object init上指定chunksize。
  • 修复打开需要编码的文件的问题。

0.1.2(2015-11-10)

  • 固定搜索方法。

0.1.1(2015-11-09)

  • 修复pypi包。

0.1.0(2015-11-09)

  • pypi上的第一个版本。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Jsonify使用Jackson来定义嵌套对象   在Swing中禁用java图形调试   java Selenium Webdriver拖放在Jenkins上不起作用   java我对一个显示器的问题有一个非常不切实际的询问   java增强的“for”循环导致ArrayIndexOutOfBoundsException   ArrayAdapter适用于Java中的安卓编程,字符串数组   linux在Ubuntu上通过PulseAudio播放Java音频文件时出错   java在Spring应用程序中加载内部(类路径)和外部属性文件   java使用Maven连接到mySQL   Java应用程序的设计   websocket在电报api java中与dc的连接   java XMLStreamException,因为xml中的(&N)   java从控制台输出到JTextArea   Java导出文本文件   java实现parseInt方法   java为什么servlet容器会同步对特定资源/servlet的多个请求的访问?   循环中的Java“while”变量   用Java编程一个国际象棋游戏,gameOver布尔不起作用   java如何获得真正的JPanel大小?