|
2 | 2 |
|
3 | 3 | S3_MEDIA_STORAGE_ENABLED = config("OW4_USE_S3", cast=bool, default=False)
|
4 | 4 | if S3_MEDIA_STORAGE_ENABLED:
|
5 |
| - from storages.backends.s3 import S3Storage |
6 |
| - |
7 | 5 | AWS_S3_REGION_NAME = config("OW4_S3_REGION", default="eu-north-1")
|
8 | 6 | AWS_STORAGE_BUCKET_NAME = config("OW4_S3_BUCKET_NAME")
|
9 | 7 | AWS_S3_CUSTOM_DOMAIN = (
|
|
18 | 16 |
|
19 | 17 | MEDIA_LOCATION = "media"
|
20 | 18 |
|
21 |
| - class MediaRootS3BotoStorage(S3Storage): |
22 |
| - def __init__(self, **kwargs): |
23 |
| - super().__init__(**(kwargs | {"location": MEDIA_LOCATION})) |
24 |
| - |
25 |
| - DEFAULT_FILE_STORAGE = "onlineweb4.settings.MediaRootS3BotoStorage" |
26 | 19 | MEDIA_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/{MEDIA_LOCATION}/"
|
27 | 20 | MEDIA_ROOT = ""
|
28 | 21 |
|
29 | 22 | STATIC_LOCATION = "static"
|
30 | 23 |
|
31 |
| - class StaticRootS3BotoStorage(S3Storage): |
32 |
| - def __init__(self, **kwargs): |
33 |
| - super().__init__(**(kwargs | {"location": STATIC_LOCATION})) |
34 | 24 |
|
35 |
| - STATICFILES_STORAGE = "onlineweb4.settings.StaticRootS3BotoStorage" |
36 | 25 | STATIC_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/{STATIC_LOCATION}/"
|
37 | 26 |
|
38 | 27 | WIKI_ATTACHMENTS_LOCAL_PATH = False
|
39 | 28 | WIKI_ATTACHMENTS_APPEND_EXTENSION = False
|
| 29 | + |
| 30 | + STORAGES = { |
| 31 | + "default": { |
| 32 | + "BACKEND": "storages.backends.s3.S3Storage", |
| 33 | + "OPTIONS": { |
| 34 | + "location": MEDIA_LOCATION, |
| 35 | + } |
| 36 | + }, |
| 37 | + "staticfiles": { |
| 38 | + "BACKEND": "storages.backends.s3.S3Storage", |
| 39 | + "OPTIONS": { |
| 40 | + "location": STATIC_LOCATION, |
| 41 | + } |
| 42 | + } |
| 43 | + } |
0 commit comments