Wednesday, June 17, 2015

[Django] Using cloud storage services as default storage backend

To use cloud storage services as default storage backend in Django – or actullay in Python, Apache's Libcloud wrapper can be a nice solution. Because it supports more than 30 providers, and has a huge community.

django-storages-redux app provides storage backends to use in Django. Good news, also supports Apache Libcloud. So you can use more than 30 cloud providers with Django. To install the app execute this:
$ pip install django-storages-redux
Also you must install Apache Libcloud:
$ pip install apache-libcloud
And enable from by adding following lines:
DEFAULT_FILE_STORAGE = 'storages.backends.apache_libcloud.LibCloudStorage'
 'google_storage': {
 'type': '',
 'user': 'yourcloudstorageapikey:)',
 'key': 'yourcloudstorageapisecretkey:)',
 'bucket': 'default-bucket-name',
 If you don't create bucket, you can create from shell:
$ ./ shell

$ from storages.backends.apache_libcloud import LibCloudStorage
$ LibCloudStorage('google_storage').driver.create_container('default-bucket-name')

No comments:

Post a Comment