Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/scottwernervt/cloudstorage

Unified cloud storage API for storage services.
https://github.com/scottwernervt/cloudstorage

amazon-web-services aws aws-s3 cloudfiles digitalocean-spaces gcs google-cloud google-cloud-storage minio python rackspace rackspace-cloud-files s3

Last synced: 3 months ago
JSON representation

Unified cloud storage API for storage services.

Awesome Lists containing this project

README

        

=============
Cloud Storage
=============

.. start-badges

.. image:: https://img.shields.io/pypi/v/cloudstorage.svg
:target: https://pypi.org/project/cloudstorage/

.. image:: https://img.shields.io/pypi/l/cloudstorage.svg
:target: https://pypi.org/project/cloudstorage/

.. image:: https://img.shields.io/pypi/wheel/cloudstorage.svg
:target: https://pypi.org/project/cloudstorage/

.. image:: https://img.shields.io/pypi/pyversions/cloudstorage.svg
:target: https://pypi.org/project/cloudstorage/

.. image:: https://travis-ci.org/scottwernervt/cloudstorage.svg?branch=master
:target: https://travis-ci.org/scottwernervt/cloudstorage/

.. image:: https://codeclimate.com/github/scottwernervt/cloudstorage/badges/gpa.svg
:target: https://codeclimate.com/github/scottwernervt/cloudstorage/

.. end-badges

`Cloud Storage`_ is a Python +3.5 package which creates a unified API for the
cloud storage services: Amazon Simple Storage Service (S3),
Microsoft Azure Storage, Minio Cloud Storage, Rackspace Cloud Files,
Google Cloud Storage, and the Local File System.

Cloud Storage is inspired by `Apache Libcloud `_.
Advantages to Apache Libcloud Storage are:

* Full Python 3 support.
* Generate temporary signed URLs for downloading and uploading files.
* Support for request and response headers like Content-Disposition.
* Pythonic! Iterate through all blobs in containers and all containers in
storage using respective objects.

Usage
=====

.. code-block:: python

>>> from cloudstorage.drivers.amazon import S3Driver
>>> storage = S3Driver(key='', secret='')

>>> container = storage.create_container('avatars')
>>> container.cdn_url
'https://avatars.s3.amazonaws.com/'

>>> avatar_blob = container.upload_blob('/path/my-avatar.png')
>>> avatar_blob.cdn_url
'https://s3.amazonaws.com/avatars/my-avatar.png'

>>> avatar_blob.generate_download_url(expires=3600)
'https://avatars.s3.amazonaws.com/my-avatar.png?'
'AWSAccessKeyId='
'&Signature='
'&Expires=1491849102'

>>> container.generate_upload_url('user-1-avatar.png', expires=3600)
{
'url': 'https://avatars.s3.amazonaws.com/',
'fields': {
'key': 'user-1-avatar.png',
'AWSAccessKeyId': '',
'policy': '',
'signature': ''
}
}

Supported Services
==================

* `Amazon S3`_
* `Google Cloud Storage`_
* `Microsoft Azure Storage`_
* `Minio Cloud Storage`_
* `Rackspace CloudFiles`_
* Local File System

Installation
============

To install Cloud Storage:

.. code-block:: bash

pip install cloudstorage

Also install the storage driver(s) you will be using:

.. code-block:: bash

pip install cloudstorage[amazon]
pip install cloudstorage[google]
pip install cloudstorage[local]
pip install cloudstorage[microsoft]
pip install cloudstorage[minio]
pip install cloudstorage[rackspace]

.. _`Amazon S3`: https://aws.amazon.com/s3/
.. _`Blackblaze B2 Cloud Storage`: https://www.backblaze.com/b2/Cloud-Storage.html
.. _`Google Cloud Storage`: https://cloud.google.com/storage/
.. _`Microsoft Azure Storage`: https://azure.microsoft.com/services/storage/
.. _`Minio Cloud Storage`: https://www.minio.io/
.. _`Rackspace CloudFiles`: https://www.rackspace.com/cloud/files
.. _`Cloud Storage`: https://github.com/scottwernervt/cloudstorage/