Created
December 7, 2016 22:50
-
-
Save bjinwright/b51e1c09711238d81c009e9d6732b7e3 to your computer and use it in GitHub Desktop.
Custon S3 Django-Storages backend made for use with CloudFront with multiple origins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.utils.encoding import filepath_to_uri | |
from storages.backends.s3boto import S3BotoStorage | |
class StaticStorage(S3BotoStorage): | |
location = settings.STATICFILES_LOCATION | |
def url(self, name, headers=None, response_headers=None, expire=None): | |
return '{}{}'.format(settings.STATIC_URL,filepath_to_uri(name)) | |
class MediaStorage(S3BotoStorage): | |
location = settings.MEDIAFILES_LOCATION | |
def url(self, name, headers=None, response_headers=None, expire=None): | |
return '{}{}'.format(settings.MEDIA_URL, filepath_to_uri(name)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment