Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make S3 private storage ignore problematic AWS_S3_CUSTOM_DOMAIN setting #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion ixc_django_docker/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,22 @@ def __init__(self, *args, **kwargs):


class S3PrivateStorage(S3MediaLocationMixin, S3PrivateMixin, S3BotoStorage):
pass

def _setup(self):
"""
Ensure this storage class *ignores* the global `AWS_S3_CUSTOM_DOMAIN`
setting because setting a custom domain has the side-effect in the
bowels of the Boto library of disabling request signing, which will
make URLs to private objects fail.

By unsetting the local `custom_domain` attribute -- which otherwise
gets set to `AWS_S3_CUSTOM_DOMAIN` -- this class will keep serving
private objects from the standard S3 bucket endpoints like
https://bucket-name.s3.amazonaws.com.
"""
super(S3PrivateStorage, self)._setup()
# Unset custom domain attribute normally set to `AWS_S3_CUSTOM_DOMAIN`
self._wrapped.custom_domain = None


class S3PublicStorage(S3MediaLocationMixin, S3PublicMixin, S3BotoStorage):
Expand Down