Google Cloud Storage Python client
Project description
GCS-Client
Google Cloud Storage Python Client
Apache 2.0 License
Documentation: https://gcs-client.readthedocs.org.
The idea is to create a client with similar functionality to Google’s appengine-gcs-client but intended for applications running from outside Google’s AppEngine.
Cloud Storage documentation can be found at Google
Features
For now only basic functionality is available:
Creating buckets
Deleting buckets
Listing buckets in a project
Getting default bucket for a project
Getting bucket attributes
Listing objects in a bucket
Getting objects attributes
Deleting objects
Reading object contents
Writing an object
Configurable retries with Truncated Exponential Backoff
Usage Example
To use gcs-client in a project you will need to have Credentials to access intended Google Cloud Storage.
Credentials are generated in Google Developers Console in the Credentials section of the API Manager of the project. Recommended credentials file is JSON.
Once you have the credentials you can start using gcs_client to access your project:
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 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'
More examples can be found in the documentation, in the Usage section.
History
0.1.4 (2015-11-16)
No changes, version bump to reload in pypi
0.1.3 (2015-11-16)
Reading an object will return data as bytes, not a bytearray.
Read specific versions of an object.
Can specify chunksize on Bucket’s open and Object init.
Add exists to buckets and project.
Fix opening files with names that needed encoding.
0.1.2 (2015-11-10)
Fix seek method.
0.1.1 (2015-11-09)
Fix Pypi package.
0.1.0 (2015-11-09)
First release on PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for gcs_client-0.1.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f05aa16fea382c5a50f3e6d94221a67ecb47877cf7632c174441834bbdaaaed6 |
|
MD5 | b75ae3b9e805f7e26f74f648af377003 |
|
BLAKE2b-256 | fdde899d38d02139aded38eca9227c65d3a967297fdaa877303eec261a6295b9 |