Skip to content

Instantly share code, notes, and snippets.

@julienb74
Forked from richleland/settings.py
Created May 30, 2012 22:55
Show Gist options
  • Save julienb74/2839434 to your computer and use it in GitHub Desktop.
Save julienb74/2839434 to your computer and use it in GitHub Desktop.
S3BotoStorage subclass for media and static buckets
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_STORAGE = 'path.to.storage.S3StaticStorage'
THUMBNAIL_DEFAULT_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = 'YOUR KEY'
AWS_SECRET_ACCESS_KEY = 'YOUR KEY'
AWS_STORAGE_BUCKET_NAME = 'media.YOURSITE.com'
AWS_STATIC_BUCKET_NAME = 'static.YOURSITE.com'
AWS_S3_CUSTOM_DOMAIN = AWS_STORAGE_BUCKET_NAME
AWS_STATIC_CUSTOM_DOMAIN = AWS_STATIC_BUCKET_NAME
STATIC_URL = 'http://%s/' % AWS_STATIC_BUCKET_NAME
MEDIA_URL = 'http://%s/' % AWS_STORAGE_BUCKET_NAME
from django.conf import settings
from storages.backends.s3boto import S3BotoStorage
class S3StaticStorage(S3BotoStorage):
"S3 storage backend that sets the static bucket."
def __init__(self, *args, **kwargs):
super(S3StaticStorage, self).__init__(bucket=settings.AWS_STATIC_BUCKET_NAME,
custom_domain=settings.AWS_STATIC_CUSTOM_DOMAIN,
*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment