Skip to content

Commit

Permalink
Added S3 CloudFront Image files
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmwatson committed Dec 11, 2024
1 parent 2ba1973 commit a1637ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
23 changes: 17 additions & 6 deletions pombola/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@
# All uploaded files world-readable
FILE_UPLOAD_PERMISSIONS = 0o644 # 'rw-r--r--'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = "/media_root/"

# Use django-pipeline for handling static files
STATICFILES_STORAGE = "pipeline.storage.PipelineCachedStorage"

Expand Down Expand Up @@ -460,12 +455,28 @@
"django_nose",
"django_extensions",
"rest_framework",
"djcelery"
"djcelery",
)

if os.environ.get("DJANGO_DEBUG_TOOLBAR", "true").lower() == "true":
INSTALLED_APPS += ("debug_toolbar",)


if os.environ.get("AWS_STORAGE_BUCKET_NAME"):
STATIC_HOST = os.environ.get("STATIC_HOST", "static.pa.org.za")
INSTALLED_APPS += ("storages",)
AWS_STORAGE_BUCKET_NAME = os.environ.get("AWS_STORAGE_BUCKET_NAME")
AWS_S3_REGION_NAME = 'af-south-1'
AWS_S3_CUSTOM_DOMAIN = STATIC_HOST
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
MEDIA_URL = '//{}/'.format(AWS_S3_CUSTOM_DOMAIN)
else:
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = "/media_root/"


def insert_after(sequence, existing_item, item_to_put_after):
"""A helper method for inserting an item after another in a sequence
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ django-pipeline==1.6.13
django-pipeline-compass-rubygem==0.1.9
django-formtools==2.1
django-cors-headers==1.3.1
django-storages==1.9.1


### API related
djangorestframework==3.4.7
Expand Down Expand Up @@ -210,3 +212,4 @@ xlrd==1.2.0
#sentry-sdk[django]==1.39.2
sentry-sdk==0.14.3

boto3==1.17.112

0 comments on commit a1637ec

Please sign in to comment.