diff --git a/cms/djangoapps/contentstore/views/assets.py b/cms/djangoapps/contentstore/views/assets.py index a06c07b4f2fa..daf47b0b3b1a 100644 --- a/cms/djangoapps/contentstore/views/assets.py +++ b/cms/djangoapps/contentstore/views/assets.py @@ -4,7 +4,6 @@ import json import logging import math -import mimetypes import re from functools import partial from urllib.parse import urljoin @@ -46,8 +45,7 @@ } -mimetypes.init() -all_mimetypes = list(mimetypes.types_map.values()) + ['text/javascript', 'text/php'] +allowed_mimetypes = settings.ALLOWED_FILE_TYPES @login_required @@ -461,7 +459,7 @@ def _get_sanitized_filename(filename): def _validate_mimetype(file_content_type): - if file_content_type in all_mimetypes: return file_content_type + if file_content_type in allowed_mimetypes: return file_content_type raise InvalidFileTypeException('{} of filetype is not supported'.format(file_content_type)) diff --git a/cms/envs/common.py b/cms/envs/common.py index a9ea495b0841..54748af34b27 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -2714,3 +2714,4 @@ DISCUSSIONS_INCONTEXT_FEEDBACK_URL = '' DISCUSSIONS_INCONTEXT_LEARNMORE_URL = '' +ALLOWED_FILE_TYPES = ['image/png', 'image/jpeg', 'application/pdf', 'application/msword', 'video/mp4'] \ No newline at end of file