This commit is contained in:
Joachim 2021-06-07 18:15:48 +02:00
parent b448d40514
commit 715cb46e1e
2 changed files with 15 additions and 14 deletions

View File

@ -188,7 +188,7 @@ PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
# Storage # Storage
USE_S3 = env.bool('USE_S3', False) USE_S3 = env.bool("USE_S3", False)
if USE_S3: if USE_S3:
# AWS settings # AWS settings
@ -199,15 +199,15 @@ if USE_S3:
AWS_S3_REGION_NAME = env("AWS_S3_REGION_NAME") AWS_S3_REGION_NAME = env("AWS_S3_REGION_NAME")
AWS_S3_ENDPOINT_URL = env("AWS_S3_ENDPOINT_URL") AWS_S3_ENDPOINT_URL = env("AWS_S3_ENDPOINT_URL")
AWS_DEFAULT_ACL = "public-read" AWS_DEFAULT_ACL = "public-read"
AWS_S3_OBJECT_PARAMETERS = {'CacheControl': 'max-age=86400'} AWS_S3_OBJECT_PARAMETERS = {"CacheControl": "max-age=86400"}
# S3 Static settings # S3 Static settings
STATIC_LOCATION = 'static' STATIC_LOCATION = "static"
STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, STATIC_LOCATION) STATIC_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, STATIC_LOCATION)
STATICFILES_STORAGE = 'bookwyrm.storage_backends.StaticStorage' STATICFILES_STORAGE = "bookwyrm.storage_backends.StaticStorage"
# S3 Media settings # S3 Media settings
MEDIA_LOCATION = 'images' MEDIA_LOCATION = "images"
MEDIA_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, MEDIA_LOCATION) MEDIA_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, MEDIA_LOCATION)
DEFAULT_FILE_STORAGE = 'bookwyrm.storage_backends.ImagesStorage' DEFAULT_FILE_STORAGE = "bookwyrm.storage_backends.ImagesStorage"
# I don't know if it's used, but the site crashes without it # I don't know if it's used, but the site crashes without it
MEDIA_ROOT = os.path.join(BASE_DIR, env("MEDIA_ROOT", "images")) MEDIA_ROOT = os.path.join(BASE_DIR, env("MEDIA_ROOT", "images"))
else: else:
@ -217,5 +217,5 @@ else:
MEDIA_ROOT = os.path.join(BASE_DIR, env("MEDIA_ROOT", "images")) MEDIA_ROOT = os.path.join(BASE_DIR, env("MEDIA_ROOT", "images"))
STATICFILES_DIRS = [ STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'), os.path.join(BASE_DIR, "static"),
] ]

View File

@ -1,11 +1,12 @@
from storages.backends.s3boto3 import S3Boto3Storage from storages.backends.s3boto3 import S3Boto3Storage
class StaticStorage(S3Boto3Storage): class StaticStorage(S3Boto3Storage):
location = 'static' location = "static"
default_acl = 'public-read' default_acl = "public-read"
class ImagesStorage(S3Boto3Storage): class ImagesStorage(S3Boto3Storage):
location = 'images' location = "images"
default_acl = 'public-read' default_acl = "public-read"
file_overwrite = False file_overwrite = False