forked from hastexo/tutor-contrib-s3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The current file storage backend, S3BotoStorage, [cannot be used for Python versions >=3.4.4](boto/boto#3433). Therfore we need to update the plugin to use the S3Boto3Storage which uses a different configuration logic. As a result, the following configuration parameters are changed: * `S3_ADDRESSING_STYLE` is added; * `S3_SIGNATURE_VERSION` is added; * `S3_REGION` is added; * `S3_AUTO_CREATE_BUCKET` is removed; Also we switch to presigned URLs which removes the need for setting bucket ACL to be public. Fixes: hastexo#8
- Loading branch information
Showing
9 changed files
with
38 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,2 @@ | ||
"FILE_UPLOAD_STORAGE_BUCKET_NAME": "{{ S3_FILE_UPLOAD_BUCKET }}", | ||
"COURSE_IMPORT_EXPORT_BUCKET": "{{ S3_COURSE_IMPORT_EXPORT_BUCKET }}", | ||
"PROFILE_IMAGE_BACKEND": { | ||
"class": "storages.backends.s3boto.S3BotoStorage", | ||
"options": { | ||
"bucket": "{{ S3_PROFILE_IMAGE_BUCKET }}", | ||
"custom_domain": "{{ S3_PROFILE_IMAGE_CUSTOM_DOMAIN }}", | ||
"headers": { | ||
"Cache-Control": "max-age-{{ S3_PROFILE_IMAGE_MAX_AGE }}" | ||
} | ||
} | ||
} | ||
"COURSE_IMPORT_EXPORT_BUCKET": "{{ S3_COURSE_IMPORT_EXPORT_BUCKET }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
"AWS_STORAGE_BUCKET_NAME": "{{ S3_STORAGE_BUCKET }}", | ||
"AWS_S3_CUSTOM_DOMAIN": "" | ||
"AWS_S3_CUSTOM_DOMAIN": "", | ||
"AWS_QUERYSTRING_AUTH": true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
COURSE_IMPORT_EXPORT_STORAGE = DEFAULT_FILE_STORAGE | ||
USER_TASKS_ARTIFACT_STORAGE = DEFAULT_FILE_STORAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
AWS_S3_HOST = "{{ S3_HOST }}" | ||
AWS_S3_PORT = {{ S3_PORT }} | ||
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" | ||
VIDEO_IMAGE_SETTINGS["STORAGE_KWARGS"]["location"] = VIDEO_IMAGE_SETTINGS["STORAGE_KWARGS"]["location"].lstrip("/") | ||
VIDEO_TRANSCRIPTS_SETTINGS["STORAGE_KWARGS"]["location"] = VIDEO_TRANSCRIPTS_SETTINGS["STORAGE_KWARGS"]["location"].lstrip("/") | ||
GRADES_DOWNLOAD["STORAGE_KWARGS"]["location"] = GRADES_DOWNLOAD["STORAGE_KWARGS"]["location"].lstrip("/") | ||
|
||
ORA2_FILEUPLOAD_BACKEND = "s3" | ||
FILE_UPLOAD_STORAGE_BUCKET_NAME = "{{ S3_STORAGE_BUCKET }}" | ||
|
||
AWS_S3_SIGNATURE_VERSION = "{{ S3_SIGNATURE_VERSION }}" | ||
AWS_S3_ENDPOINT_URL = "{{ "https" if ENABLE_HTTPS else "http" }}://{{ S3_HOST }}:{{ S3_PORT }}" | ||
AWS_S3_USE_SSL = {{ "True" if S3_USE_SSL else "False" }} | ||
AWS_S3_SECURE_URLS = {{ "True" if S3_USE_SSL else "False" }} | ||
AWS_S3_CALLING_FORMAT = "boto.s3.connection.OrdinaryCallingFormat" | ||
AWS_AUTO_CREATE_BUCKET = {{ "True" if S3_AUTO_CREATE_BUCKET else "False" }} | ||
AWS_DEFAULT_ACL = None # inherit from the bucket | ||
AWS_S3_ADDRESSING_STYLE = "{{ S3_ADDRESSING_STYLE }}" | ||
|
||
# Configuring boto is required for ora2 because ora2 does not read | ||
# host/port/ssl settings from django. Hence this hack. | ||
# http://docs.pythonboto.org/en/latest/boto_config_tut.html | ||
import os | ||
os.environ["AWS_CREDENTIAL_FILE"] = "/tmp/boto.cfg" | ||
with open("/tmp/boto.cfg", "w") as f: | ||
f.write("""[Boto] | ||
is_secure = {{ "True" if S3_USE_SSL else "False" }} | ||
[s3] | ||
host = {{ S3_HOST }}:{{ S3_PORT }} | ||
calling_format = boto.s3.connection.OrdinaryCallingFormat""") | ||
AWS_S3_REGION_NAME = "{{ S3_REGION }}" | ||
AWS_QUERYSTRING_EXPIRE = 7 * 24 * 60 * 60 # 1 week: this is necessary to generate valid download urls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
ORA2_FILEUPLOAD_BACKEND = "s3" | ||
PROFILE_IMAGE_BACKEND = { | ||
"class": DEFAULT_FILE_STORAGE, | ||
"options": { | ||
"location": PROFILE_IMAGE_BACKEND["options"]["location"].lstrip("/"), | ||
# the following non empty property is necessary in development | ||
"base_url": "dummyprofileimagebaseurl", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters