Configure PROFILE_IMAGE_BACKEND when using AWS s3 #370
Conversation
@@ -48,6 +48,13 @@ def swift_container_names(self): | |||
""" | |||
return [self.swift_container_name] | |||
|
|||
@property | |||
def s3_custom_domain(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to /mixins/storage.py#S3BucketInstanceMixin
? There are a few other related properties there.
@@ -61,13 +68,29 @@ def _get_s3_settings(self): | |||
# using shared s3 buckets | |||
"EDXAPP_AWS_LOCATION": self.swift_container_name, | |||
"EDXAPP_DEFAULT_FILE_STORAGE": 'storages.backends.s3boto.S3BotoStorage', | |||
|
|||
# Set up S3 image backend | |||
# https://github.com/edx/configuration/blob/master/playbooks/roles/edxapp/defaults/main.yml#L688 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reference will get out of date so we can leave it out. :)
"location": '{}/{}'.format(self.swift_container_name, 'profile-images'), | ||
"custom_domain": self.s3_custom_domain, | ||
"access_key": self.s3_access_key, | ||
"secret_key": self.s3_secret_access_key, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Since django-storages defaults to the global ones can we get away with not passing the ones which are already set? I think only location
and headers
are unique here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Thanks for the tip :)
from instance.tests.base import TestCase | ||
from instance.tests.models.factories.openedx_appserver import make_test_appserver | ||
from instance.tests.models.factories.openedx_instance import OpenEdXInstanceFactory | ||
from instance.tests.models.factories.openedx_appserver import \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edX uses 120 as line length so you may want to set that in your IDE and undo these formatting changes.
Signed-off-by: Gustavo Sampaio <gbritosampaio@gmail.com>
See SE-559
Turns out that to upload profile images to aws, the profile images backend has to be configured similar to the default file storage. This PR adds the ansible variable to the
configuration_storage_settings
entry in OCIM.Ref: https://github.com/edx/configuration/blob/master/playbooks/roles/edxapp/defaults/main.yml#L688
Sandbox URL:
Sandbox with the current change in the extra settings: https://gustavo-profile-image-test.stage.opencraft.hosting/
Testing instructions:
EDXAPP_PROFILE_IMAGE_BACKEND
is set and matches:Reviewers