Skip to content

Commit

Permalink
Updated AWS Settings
Browse files Browse the repository at this point in the history
Media aren't served via S3 now, so this should fix an issue
  • Loading branch information
bartczak-pa committed Sep 6, 2024
1 parent 3256f8f commit 72a1399
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_BUCKET_NAME")
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
AWS_QUERYSTRING_AUTH = False
AWS_QUERYSTRING_AUTH = True
# DO NOT change these unless you know what you're doing.
_AWS_EXPIRY = 60 * 60 * 24 * 7
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
Expand All @@ -94,21 +94,31 @@
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#cloudfront
AWS_S3_CUSTOM_DOMAIN = env("DJANGO_AWS_S3_CUSTOM_DOMAIN", default=None)
aws_s3_domain = AWS_S3_CUSTOM_DOMAIN or f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com"

# S3 BUCKET CONFIGURATION FOR TEST

AWS_S3_SIGNATURE_VERSION = env("AWS_S3_SIGNATURE_VERSION", default="")


# STATIC & MEDIA
# ------------------------
STORAGES = {
"default": {
"BACKEND": "storages.backends.s3.S3Storage",
"BACKEND": "storages.backends.s3boto3.S3Boto3Storage",
"OPTIONS": {
"location": "media",
"file_overwrite": False,
"file_overwrite": True,
},
},
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedStaticFilesStorage",
},
}
MEDIA_URL = f"https://{aws_s3_domain}/media/"

MEDIA_URL = (
f"https://{AWS_STORAGE_BUCKET_NAME}.s3.{AWS_S3_REGION_NAME}.amazonaws.com/media/"
)


# EMAIL
# ------------------------------------------------------------------------------
Expand Down

0 comments on commit 72a1399

Please sign in to comment.