|
104 | 104 | AWS_STORAGE_DIR = os.getenv('AWS_STORAGE_DIR', 'oscms-test') |
105 | 105 | AWS_S3_CUSTOM_DOMAIN = os.getenv('AWS_S3_CUSTOM_DOMAIN', 'assets.openstax.org') |
106 | 106 | AWS_DEFAULT_ACL = 'public-read' |
107 | | -AWS_HEADERS = {'Access-Control-Allow-Origin': '*'} |
108 | 107 |
|
109 | 108 | ################ |
110 | 109 | # Static/Media # |
111 | 110 | ################ |
112 | | - |
113 | | -# Use local storage for media and static files in local environment |
114 | 111 | if DEBUG or ENVIRONMENT == 'test': |
115 | | - DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage' |
| 112 | + # Local development storage configuration |
| 113 | + STORAGES = { |
| 114 | + "default": { |
| 115 | + "BACKEND": "django.core.files.storage.FileSystemStorage", |
| 116 | + }, |
| 117 | + "staticfiles": { |
| 118 | + "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", |
| 119 | + }, |
| 120 | + } |
116 | 121 | else: |
117 | 122 | # S3 media storage using custom backend |
118 | 123 | MEDIAFILES_LOCATION = '{}/media'.format(AWS_STORAGE_DIR) |
119 | 124 | MEDIA_URL = "https://%s/%s/media/" % (AWS_S3_CUSTOM_DOMAIN, AWS_STORAGE_DIR) |
120 | | - DEFAULT_FILE_STORAGE = 'openstax.custom_storages.MediaStorage' |
121 | | - |
122 | | -# Static files are stored on the server and served by nginx |
123 | | -STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' |
| 125 | + |
| 126 | + STORAGES = { |
| 127 | + "default": { |
| 128 | + "BACKEND": "storages.backends.s3boto3.S3Boto3Storage", |
| 129 | + "OPTIONS": { |
| 130 | + "bucket_name": AWS_STORAGE_BUCKET_NAME, |
| 131 | + "custom_domain": AWS_S3_CUSTOM_DOMAIN, |
| 132 | + "default_acl": AWS_DEFAULT_ACL, |
| 133 | + "location": MEDIAFILES_LOCATION, |
| 134 | + "file_overwrite": False, |
| 135 | + "querystring_auth": False, |
| 136 | + "use_ssl": True, |
| 137 | + }, |
| 138 | + }, |
| 139 | + "staticfiles": { |
| 140 | + "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", |
| 141 | + }, |
| 142 | + } |
124 | 143 |
|
125 | 144 | # Absolute path to the directory static files should be collected to. |
126 | 145 | # Don't put anything in this directory yourself; store your static files |
|
0 commit comments