aboutsummaryrefslogtreecommitdiffstats
path: root/config/settings/base.py
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-05-14 12:53:28 +0100
committerMatthew Lemon <y@yulqen.org>2024-05-14 12:53:28 +0100
commit46f11648d902b22a177b878e35d6049a7a127ce7 (patch)
treef59f6630717bc9097c988a6d8d3eebe4ad548f1d /config/settings/base.py
parentb5e2c4b9a7aab20db6dd6072a01abd114e8e55de (diff)
Can now upload to Spaces
Diffstat (limited to 'config/settings/base.py')
-rw-r--r--config/settings/base.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/config/settings/base.py b/config/settings/base.py
index 3c11aee..16d79eb 100644
--- a/config/settings/base.py
+++ b/config/settings/base.py
@@ -314,6 +314,38 @@ SOCIALACCOUNT_ADAPTER = "pyblackbird_cc.users.adapters.SocialAccountAdapter"
# https://docs.allauth.org/en/latest/socialaccount/configuration.html
SOCIALACCOUNT_FORMS = {"signup": "pyblackbird_cc.users.forms.UserSocialSignupForm"}
+# STORAGES
+# ------------------------------------------------------------------------------
+# https://django-storages.readthedocs.io/en/latest/#installation
+INSTALLED_APPS += ["storages"]
+# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_ACCESS_KEY_ID = env("DJANGO_AWS_ACCESS_KEY_ID")
+AWS_ACCESS_KEY_ID = env("SPACES_KEY")
+# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY")
+AWS_SECRET_ACCESS_KEY = env("SPACES_SECRET")
+# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+# AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_BUCKET_NAME")
+AWS_STORAGE_BUCKET_NAME = env("SPACES_BUCKET_NAME")
+# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+AWS_QUERYSTRING_AUTH = False
+# 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
+AWS_S3_OBJECT_PARAMETERS = {
+ "CacheControl": f"max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate",
+}
+# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+AWS_S3_MAX_MEMORY_SIZE = env.int(
+ "DJANGO_AWS_S3_MAX_MEMORY_SIZE",
+ default=100_000_000, # 100MB
+)
+# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
+AWS_S3_REGION_NAME = env("DJANGO_AWS_S3_REGION_NAME", default=None)
+# 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"
+AWS_S3_ENDPOINT_URL = env("SPACES_ENDPOINT_URL")
# Your stuff...
# ------------------------------------------------------------------------------