From 75d7ee688b54c12c71477db92a15fabcc1de2122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Mon, 27 Aug 2018 23:19:16 +0200 Subject: [PATCH] Fix profile image upload Media file upload, such as video files or profile images, were uploaded to /edx/var/edxapp/media because the MEDIA_ROOT setting is defined in common.py. Close #54. --- config/openedx/universal/lms/development.py | 5 +++++ config/openedx/universal/lms/production.py | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config/openedx/universal/lms/development.py b/config/openedx/universal/lms/development.py index b10ef2c..c3d702c 100644 --- a/config/openedx/universal/lms/development.py +++ b/config/openedx/universal/lms/development.py @@ -15,3 +15,8 @@ import os for folder in [LOG_DIR, MEDIA_ROOT, STATIC_ROOT_BASE]: if not os.path.exists(folder): os.makedirs(folder) + +# Fix media files paths +VIDEO_IMAGE_SETTINGS['STORAGE_KWARGS']['location'] = MEDIA_ROOT +VIDEO_TRANSCRIPTS_SETTINGS['STORAGE_KWARGS']['location'] = MEDIA_ROOT +PROFILE_IMAGE_BACKEND['options']['location'] = os.path.join(MEDIA_ROOT, 'profile-images/') diff --git a/config/openedx/universal/lms/production.py b/config/openedx/universal/lms/production.py index 9cfb267..b292558 100644 --- a/config/openedx/universal/lms/production.py +++ b/config/openedx/universal/lms/production.py @@ -1,8 +1,9 @@ -import os from ..aws import * +# Load module store settings from config files update_module_store_settings(MODULESTORE, doc_store_settings=DOC_STORE_CONFIG) +# Set uploaded media file path MEDIA_ROOT = "/openedx/data/uploads/" # Change syslog-based loggers which don't work inside docker containers @@ -10,10 +11,16 @@ LOGGING['handlers']['local'] = LOGGING['handlers']['console'].copy() LOGGING['handlers']['tracking'] = LOGGING['handlers']['console'].copy() # Create folders if necessary +import os for folder in [LOG_DIR, MEDIA_ROOT, STATIC_ROOT_BASE]: if not os.path.exists(folder): os.makedirs(folder) +# Fix media files paths +VIDEO_IMAGE_SETTINGS['STORAGE_KWARGS']['location'] = MEDIA_ROOT +VIDEO_TRANSCRIPTS_SETTINGS['STORAGE_KWARGS']['location'] = MEDIA_ROOT +PROFILE_IMAGE_BACKEND['options']['location'] = os.path.join(MEDIA_ROOT, 'profile-images/') + ALLOWED_HOSTS = [ ENV_TOKENS.get('LMS_BASE'), FEATURES['PREVIEW_LMS_BASE'],