From 207d82156428df475c0cb2510ce561290c8a6ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 1 Aug 2016 12:55:53 +0200 Subject: [PATCH] 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. --- pillar/api/file_storage.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pillar/api/file_storage.py b/pillar/api/file_storage.py index 98b91e89..902d8fcd 100644 --- a/pillar/api/file_storage.py +++ b/pillar/api/file_storage.py @@ -34,9 +34,15 @@ file_storage = Blueprint('file_storage', __name__, template_folder='templates', 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 mimetypes.add_type('application/x-blender', '.blend') mimetypes.add_type('application/x-radiance-hdr', '.hdr') +mimetypes.add_type('application/x-exr', '.exr') @file_storage.route('/gcs///') @@ -565,6 +571,12 @@ def override_content_type(uploaded_file): # Possibly use the browser-provided mime type mimetype = uploaded_file.mimetype + + try: + mimetype = OVERRIDE_MIMETYPES[mimetype] + except KeyError: + pass + if '/' in mimetype: mimecat = mimetype.split('/')[0] if mimecat in {'video', 'audio', 'image'}: