Przeglądaj źródła

Always download a file in binary.

Fixes #817.
Jason Grout 8 lat temu
rodzic
commit
0053d9e64a
1 zmienionych plików z 2 dodań i 2 usunięć
  1. 2 2
      src/filebrowser/model.ts

+ 2 - 2
src/filebrowser/model.ts

@@ -214,9 +214,9 @@ class FileBrowserModel implements IDisposable {
   download(path: string): Promise<IContents.IModel> {
     let normalizePath = Private.normalizePath;
     path = normalizePath(this._model.path, path);
-    return this._manager.contents.get(path, { content: true }).then(contents => {
+    return this._manager.contents.get(path, { content: true, type: 'file', format: 'base64' }).then(contents => {
       let element = document.createElement('a');
-      element.setAttribute('href', 'data:text/text;charset=utf-8,' +      encodeURI(contents.content));
+      element.setAttribute('href', `data:${contents.mimetype};base64,${contents.content}`);
       element.setAttribute('download', contents.name);
       element.click();
       return contents;