|
57 | 57 |
|
58 | 58 | SESSION_ENGINE = "api.models.session"
|
59 | 59 |
|
| 60 | + |
| 61 | +s3_storage = { |
| 62 | + "BACKEND": "storages.backends.s3.S3Storage", |
| 63 | + # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings |
| 64 | + "OPTIONS": { |
| 65 | + "bucket_name": os.getenv("S3_STORAGE_BUCKET_NAME"), |
| 66 | + "default_acl": os.getenv("S3_STORAGE_DEFAULT_ACL"), |
| 67 | + "location": os.getenv("S3_STORAGE_LOCATION", ""), |
| 68 | + "region_name": os.getenv("S3_STORAGE_REGION_NAME"), |
| 69 | + "custom_domain": os.getenv("S3_STORAGE_CUSTOM_DOMAIN"), |
| 70 | + "addressing_style": os.getenv("S3_STORAGE_ADDRESSING_STYLE"), |
| 71 | + "querystring_auth": bool( |
| 72 | + int(os.getenv("S3_STORAGE_QUERYSTRING_AUTH", "1")) |
| 73 | + ), |
| 74 | + "querystring_expire": int( |
| 75 | + os.getenv("S3_STORAGE_QUERYSTRING_EXPIRE", "3600") |
| 76 | + ), |
| 77 | + }, |
| 78 | +} |
| 79 | + |
| 80 | + |
60 | 81 | # TODO: delete
|
61 | 82 | STORAGES: t.Dict[str, t.Any] = { # type: ignore[no-redef]
|
62 | 83 | "default": (
|
63 | 84 | {
|
64 | 85 | "BACKEND": "django.core.files.storage.FileSystemStorage",
|
65 | 86 | }
|
66 | 87 | if ENV == "local"
|
67 |
| - else { |
68 |
| - "BACKEND": "storages.backends.s3.S3Storage", |
69 |
| - # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings |
70 |
| - "OPTIONS": { |
71 |
| - "bucket_name": os.getenv("S3_STORAGE_BUCKET_NAME"), |
72 |
| - "default_acl": os.getenv("S3_STORAGE_DEFAULT_ACL"), |
73 |
| - "location": os.getenv("S3_STORAGE_LOCATION", ""), |
74 |
| - "region_name": os.getenv("S3_STORAGE_REGION_NAME"), |
75 |
| - # "custom_domain": os.getenv("S3_STORAGE_CUSTOM_DOMAIN"), |
76 |
| - "addressing_style": os.getenv("S3_STORAGE_ADDRESSING_STYLE"), |
77 |
| - "querystring_auth": bool( |
78 |
| - int(os.getenv("S3_STORAGE_QUERYSTRING_AUTH", "1")) |
79 |
| - ), |
80 |
| - "querystring_expire": int( |
81 |
| - os.getenv("S3_STORAGE_QUERYSTRING_EXPIRE", "3600") |
82 |
| - ), |
83 |
| - }, |
| 88 | + else s3_storage |
| 89 | + ), |
| 90 | + "staticfiles": ( |
| 91 | + { |
| 92 | + "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", |
84 | 93 | }
|
| 94 | + if ENV == "local" |
| 95 | + else s3_storage |
85 | 96 | ),
|
86 |
| - "staticfiles": { |
87 |
| - "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", |
88 |
| - }, |
89 | 97 | }
|
0 commit comments