Skip to content

Commit

Permalink
fix: use file system storage locally and adapt AWS variables
Browse files Browse the repository at this point in the history
  • Loading branch information
FinalAngel committed Apr 11, 2024
1 parent 9ef68ea commit 3552f02
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,35 @@
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles_collected')


# AWS S3 storage configuration
AWS_STORAGE_BUCKET_NAME = os.environ.get('DEFAULT_STORAGE_BUCKET', '')
AWS_ACCESS_KEY_ID = os.environ.get('DEFAULT_STORAGE_ACCESS_KEY_ID', '')
AWS_SECRET_ACCESS_KEY = os.environ.get('DEFAULT_STORAGE_SECRET_ACCESS_KEY', '')
AWS_S3_CUSTOM_DOMAIN = os.environ.get('DEFAULT_STORAGE_CUSTOM_DOMAIN', '')
AWS_S3_REGION_NAME = os.environ.get('DEFAULT_STORAGE_REGION', '')
AWS_S3_OBJECT_PARAMETERS = {
'ACL': 'public-read',
'CacheControl': 'max-age=86400',
}
AWS_S3_FILE_OVERWRITE = False


# Default storage settings, with the staticfiles storage updated.
# See https://docs.djangoproject.com/en/5.0/ref/settings/#std-setting-STORAGES
STORAGE_BACKEND = "django.core.files.storage.FileSystemStorage"

if AWS_SECRET_ACCESS_KEY:
STORAGE_BACKEND = "storages.backends.s3boto3.S3Boto3Storage"

STORAGES = {
"default": {
"BACKEND": "storages.backends.s3boto3.S3Boto3Storage",
"BACKEND": STORAGE_BACKEND,
},
# ManifestStaticFilesStorage is recommended in production, to prevent
# outdated JavaScript / CSS assets being served from cache
# See https://docs.djangoproject.com/en/5.0/ref/contrib/staticfiles/#manifeststaticfilesstorage
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
"BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
},
}

Expand Down Expand Up @@ -242,15 +262,3 @@

CMS_CONFIRM_VERSION4 = True
DJANGOCMS_VERSIONING_ALLOW_DELETING_VERSIONS = True


# AWS S3 storage configuration
AWS_ACCESS_KEY_ID = os.environ.get('DEFAULT_STORAGE_ACCESS_KEY_ID', '')
AWS_SECRET_ACCESS_KEY = os.environ.get('DEFAULT_STORAGE_SECRET_ACCESS_KEY', '')
AWS_S3_REGION_NAME = os.environ.get('DEFAULT_STORAGE_REGION', '')
AWS_STORAGE_BUCKET_NAME=os.environ.get('DEFAULT_STORAGE_BUCKET', '')
AWS_S3_CUSTOM_DOMAIN = os.environ.get('DEFAULT_STORAGE_CUSTOM_DOMAIN', '')
AWS_S3_OBJECT_PARAMETERS = {
'ACL': 'public-read',
'CacheControl': 'max-age=86400',
}

0 comments on commit 3552f02

Please sign in to comment.