From 407e63cb8061a6d15f8a32f90cd41c19953625fd Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 8 Dec 2014 14:02:19 -0800 Subject: [PATCH] set default mimetype to octet-stream for binary files mimetype only specified if content=True --- IPython/html/services/contents/filemanager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/IPython/html/services/contents/filemanager.py b/IPython/html/services/contents/filemanager.py index 2ca1f41c5..51e0d8592 100644 --- a/IPython/html/services/contents/filemanager.py +++ b/IPython/html/services/contents/filemanager.py @@ -268,7 +268,6 @@ class FileContentsManager(ContentsManager): model['type'] = 'file' os_path = self._get_os_path(path) - model['mimetype'] = mimetypes.guess_type(os_path)[0] or 'text/plain' if content: if not os.path.isfile(os_path): @@ -285,10 +284,14 @@ class FileContentsManager(ContentsManager): raise web.HTTPError(400, "%s is not UTF-8 encoded" % path) else: model['format'] = 'text' + default_mime = 'text/plain' if model['content'] is None: model['content'] = base64.encodestring(bcontent).decode('ascii') model['format'] = 'base64' + default_mime = 'application/octet-stream' + + model['mimetype'] = mimetypes.guess_type(os_path)[0] or default_mime return model