From: Boris Bobrov Date: Thu, 12 Jul 2018 10:50:54 +0000 (+0200) Subject: always guess the same filetype X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8e5b7f633910de7e1429f02f0661fcbe311600fb;p=mediagoblin.git always guess the same filetype --- diff --git a/mediagoblin/api/views.py b/mediagoblin/api/views.py index b25300f0..dfa9dfa2 100644 --- a/mediagoblin/api/views.py +++ b/mediagoblin/api/views.py @@ -119,8 +119,11 @@ def uploads_endpoint(request): if "X-File-Name" in request.headers: filename = request.headers["X-File-Name"] else: - filename = mimetypes.guess_all_extensions(mimetype) - filename = 'unknown' + filename[0] if filename else filename + filenames = sorted(mimetypes.guess_all_extensions(mimetype)) + if not filenames: + return json_error('Unknown mimetype: {}'.format(mimetype), + status=415) + filename = 'unknown{0}'.format(filenames[0]) file_data = FileStorage( stream=io.BytesIO(request.data),