From b6e543986098716a435882e99b0c98a0436ba0c9 Mon Sep 17 00:00:00 2001 From: lilia Date: Wed, 19 Apr 2017 15:57:54 -0700 Subject: [PATCH] Fix saving attachments // FREEBIE --- js/views/attachment_view.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/js/views/attachment_view.js b/js/views/attachment_view.js index 59f396d13..e95e62f62 100644 --- a/js/views/attachment_view.js +++ b/js/views/attachment_view.js @@ -172,22 +172,10 @@ return suggestion; }, saveFile: function() { - var blob = this.blob; - var w = extension.windows.getViews()[0]; - if (w && w.chrome && w.chrome.fileSystem) { - w.chrome.fileSystem.chooseEntry({ - type: 'saveFile', suggestedName: this.suggestedName() - }, function(entry) { - if (!entry) { - return; - } - entry.createWriter(function(fileWriter) { - fileWriter.write(blob); - }); - }); - } else { - console.log('Failed to get window'); - } + var url = window.URL.createObjectURL(this.blob, { type: 'octet/stream' }); + var a = $('').attr({ href: url, download: this.suggestedName() }); + a[0].click(); + window.URL.revokeObjectURL(url); }, render: function() { if (!this.isImage()) {