Override image/x-exr mimetype with application/x-exr

This prevents us from handling EXR files as images, at least until the
time when we can properly thumbnail those.
This commit is contained in:
Sybren A. Stüvel 2016-08-01 12:55:53 +02:00
parent b70af6a0be
commit 3c63649ce1

View File

@ -39,9 +39,15 @@ file_storage = Blueprint('file_storage', __name__,
template_folder='templates', template_folder='templates',
static_folder='../../static/storage', ) static_folder='../../static/storage', )
# Overrides for browser-specified mimetypes
OVERRIDE_MIMETYPES = {
# We don't want to thumbnail EXR files right now, so don't handle as image/...
'image/x-exr': 'application/x-exr',
}
# Add our own extensions to the mimetypes package # Add our own extensions to the mimetypes package
mimetypes.add_type('application/x-blender', '.blend') mimetypes.add_type('application/x-blender', '.blend')
mimetypes.add_type('application/x-radiance-hdr', '.hdr') mimetypes.add_type('application/x-radiance-hdr', '.hdr')
mimetypes.add_type('application/x-exr', '.exr')
@file_storage.route('/gcs/<bucket_name>/<subdir>/') @file_storage.route('/gcs/<bucket_name>/<subdir>/')
@ -544,6 +550,12 @@ def override_content_type(uploaded_file):
# Possibly use the browser-provided mime type # Possibly use the browser-provided mime type
mimetype = uploaded_file.mimetype mimetype = uploaded_file.mimetype
try:
mimetype = OVERRIDE_MIMETYPES[mimetype]
except KeyError:
pass
if '/' in mimetype: if '/' in mimetype:
mimecat = mimetype.split('/')[0] mimecat = mimetype.split('/')[0]
if mimecat in {'video', 'audio', 'image'}: if mimecat in {'video', 'audio', 'image'}: