Djangae provides two storage backends.
If you've imported
djangae.settings_base.*, then the default backend is
djangae.storage.CloudStorage. If you want to configure it manually in a settings module, you can set your
DEFAULT_FILE_STORAGE accordingly e.g.
DEFAULT_FILE_STORAGE = 'djangae.storage.CloudStorage'.
djangae.storage.CloudStorage is a django storage backend that works with Google Cloud Storage, you can treat it just
as you would with other storage backends. Google Cloud storage is a general purpose storage backend.
To use this you need to install the
- Cloud storage will use the default bucket name
CLOUD_STORAGE_BUCKETunless specified with
BUCKET_KEYin your settings.py
You can serve files directly from cloudstorage with the key or you can use the included
* serve_file will create a proxy in the blobstore which can then be used to serve the file, this may be more useful for access control.
Images in this model will be publicly accessible and stored in main bucket of application.
Allowed storage permission levels are defined in docs - XML column.
from django.db import models from djangae import fields, storage public_storage = storage.CloudStorage(google_acl='public-read') class Image(models.Model): image_file = models.ImageField(upload_to='/somewhere/', storage=public_storage)
djangae.storage.BlobstoreStorage is a storage backend that uses the blobstore, this may be more suitable for temporary file needs
or file processing and is used as a proxy for serving files from Cloud Storage.