Skip to content

Commit

Permalink
fix: storages
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Feb 10, 2025
1 parent 0ccc612 commit c45d53b
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions codeforlife/settings/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,24 +284,49 @@ def get_databases():

STORAGES: t.Dict[str, t.Any] = {
"default": (
{
"BACKEND": "django.core.files.storage.FileSystemStorage",
{"BACKEND": "django.core.files.storage.FileSystemStorage"}
if ENV == "local"
else {
"BACKEND": "storages.backends.s3.S3Storage",
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
"OPTIONS": {
"bucket_name": os.getenv("STORAGES_DEFAULT_S3_BUCKET_NAME"),
"default_acl": os.getenv("STORAGES_DEFAULT_S3_DEFAULT_ACL"),
"location": os.getenv("STORAGES_DEFAULT_S3_LOCATION", ""),
"region_name": os.getenv("STORAGES_DEFAULT_S3_REGION_NAME"),
"querystring_auth": bool(
int(os.getenv("STORAGES_DEFAULT_S3_QUERYSTRING_AUTH", "1"))
),
"querystring_expire": int(
os.getenv("STORAGES_DEFAULT_S3_QUERYSTRING_EXPIRE", "3600")
),
},
}
),
"staticfiles": (
{"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"}
if ENV == "local"
else {
"BACKEND": "storages.backends.s3.S3Storage",
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
"OPTIONS": {
"bucket_name": os.getenv("S3_STORAGE_BUCKET_NAME"),
"default_acl": os.getenv("S3_STORAGE_DEFAULT_ACL"),
"location": os.getenv("S3_STORAGE_LOCATION"),
"region_name": os.getenv("S3_STORAGE_REGION_NAME"),
"custom_domain": os.getenv("S3_STORAGE_CUSTOM_DOMAIN"),
"addressing_style": os.getenv("S3_STORAGE_ADDRESSING_STYLE"),
"bucket_name": os.getenv("STORAGES_STATICFILES_S3_BUCKET_NAME"),
"default_acl": os.getenv("STORAGES_STATICFILES_S3_DEFAULT_ACL"),
"location": os.getenv("STORAGES_STATICFILES_S3_LOCATION", ""),
"region_name": os.getenv("STORAGES_STATICFILES_S3_REGION_NAME"),
"querystring_auth": bool(
int(
os.getenv(
"STORAGES_STATICFILES_S3_QUERYSTRING_AUTH", "1"
)
)
),
"querystring_expire": int(
os.getenv(
"STORAGES_STATICFILES_S3_QUERYSTRING_EXPIRE", "3600"
)
),
},
}
),
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
},
}

0 comments on commit c45d53b

Please sign in to comment.