projects
/
mediagoblin.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f8f471e
)
always guess the same filetype
author
Boris Bobrov
<breton@cynicmansion.ru>
Thu, 12 Jul 2018 10:50:54 +0000
(12:50 +0200)
committer
Boris Bobrov
<breton@cynicmansion.ru>
Thu, 12 Jul 2018 10:50:54 +0000
(12:50 +0200)
mediagoblin/api/views.py
patch
|
blob
|
blame
|
history
diff --git
a/mediagoblin/api/views.py
b/mediagoblin/api/views.py
index b25300f0854dca95cb1a94558d260e6686efd849..dfa9dfa22099d22883ee19f2a017178144f85548 100644
(file)
--- 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),