Skip to main content

Django file storage backend for Google Cloud Storage

Project description

Based on Google Cloud Storage JSON API.

Written using Google Cloud Python Client library.

Quick start

$ pip install django-gcs

Update settings.py

DJANGO_GCS = {
    'bucket': 'bucket-name',
    'http': get_http_credentials
}

Settings

DJANGO_GCS = {
    'bucket': None,
    'project': '',
    'credentials': None,
    'http': None,
    'cache_control': ['no-cache']
}
  • bucket name of the bucket on google cloud storage.

  • project google project name (not required).

  • credentials oauth2 credentials

  • http httplib2.Http instance or callable that returns httplib2.Http instance

  • cache_control is a list of strings. By default [‘no-cache’]

Note: One of credentials or http should be provided for authentication.

Usage

Set storage globally:

DEFAULT_FILE_STORAGE = 'django_gcs.GoogleCloudStorage'

Or per model:

from django_gcs import GoogleCloudStorage

class FileModel(models.Model):
    file = models.ImageField(storage=GoogleCloudStorage(bucket='some-bucket'))

Example how to generate HTTP object to make request.

import pickle
import httplib2

def get_http_credentials():
    with open('google/oauth2/credentials/file', 'r') as f:
        credentials = pickle.load(f)
        http_credentials = credentials.authorize(httplib2.Http())
    return http_credentials

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

django-gcs-0.1.1.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file django-gcs-0.1.1.tar.gz.

File metadata

  • Download URL: django-gcs-0.1.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-gcs-0.1.1.tar.gz
Algorithm Hash digest
SHA256 29be02fb80e8aea475b799f8e7602a41f0a1d0a9acf544cde31b34bf4c74fd57
MD5 9baba2514f08c0de3d6baebf098c256d
BLAKE2b-256 7fd868d498079692772979190010c16f3e6493753ffa0831829b79383509db38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page