From 896e2bc147952c7b5365f3ebc9f61fca22bb7939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 7 Jul 2016 19:05:42 +0200 Subject: [PATCH] Override content type before creating file document in MongoDB --- pillar/application/modules/file_storage.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pillar/application/modules/file_storage.py b/pillar/application/modules/file_storage.py index f2102d04..7ba559ac 100644 --- a/pillar/application/modules/file_storage.py +++ b/pillar/application/modules/file_storage.py @@ -536,14 +536,13 @@ def stream_to_gcs(project_id): authentication.current_user_id()) uploaded_file = request.files['file'] - file_id, internal_fname, status = create_file_doc_for_upload(project_oid, uploaded_file) - override_content_type(uploaded_file) - if not uploaded_file.content_type: log.warning('File uploaded to project %s without content type.', project_oid) raise BadRequest('Missing content type.') + file_id, internal_fname, status = create_file_doc_for_upload(project_oid, uploaded_file) + if uploaded_file.content_type.startswith('image/'): # We need to do local thumbnailing, so we have to write the stream # both to Google Cloud Storage and to local storage.