Django Google Drive Storage

Storage implementation for Django that interacts with Google Drive

View the Project on GitHub torre76/django-googledrive-storage

How it works

Django Google Drive Storage is an implementation of Django Storage that uses Google Drive ad backend.

Please notice that with this implementation you could not save or load data from a user's Drive. You can use only a Drive dedicated to a Google Project. This means that:

Having stated that, with this storage you gain a 25GB space hosted on Google Server where to store your data using Django models.

Prerequisites

To use this storage, you have to:

Installation

This storage is hosted on PyPI. It can be easily installed thru pip:

pip install django-googledrive-storage

Setup

Once installed, there are some few steps to configure the storage:

INSTALLED_APPS = (
    ...,
    'django.contrib.staticfiles',
    'gdstorage'
)
#
# Google Drive Storage Settings
#

GOOGLE_DRIVE_STORAGE = {
    'service_account':{
        'email': <project email associated by Google>,
        'private_key_file_path': <p12 certificate file path, relative to your project, obtained by Google>
    }
}

The email should be the email Google assigned to your project, while the private_key_file_path must be the p12 file obtained by Google.

from gdstorage.storage import GoogleDriveStorage

# Define Google Drive Storage
gd_storage = GoogleDriveStorage()

Use

Once configured you could use it as any storage for Django:

class Map(models.Model):
    id = models.AutoField( primary_key=True)
    map_name = models.CharField(max_length=200)
    map_data = models.FileField(upload_to='/maps', storage=gd_storage)