Fix saving attachments
// FREEBIE
This commit is contained in:
parent
2ae48ad9cd
commit
b6e5439860
1 changed files with 4 additions and 16 deletions
|
@ -172,22 +172,10 @@
|
||||||
return suggestion;
|
return suggestion;
|
||||||
},
|
},
|
||||||
saveFile: function() {
|
saveFile: function() {
|
||||||
var blob = this.blob;
|
var url = window.URL.createObjectURL(this.blob, { type: 'octet/stream' });
|
||||||
var w = extension.windows.getViews()[0];
|
var a = $('<a>').attr({ href: url, download: this.suggestedName() });
|
||||||
if (w && w.chrome && w.chrome.fileSystem) {
|
a[0].click();
|
||||||
w.chrome.fileSystem.chooseEntry({
|
window.URL.revokeObjectURL(url);
|
||||||
type: 'saveFile', suggestedName: this.suggestedName()
|
|
||||||
}, function(entry) {
|
|
||||||
if (!entry) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
entry.createWriter(function(fileWriter) {
|
|
||||||
fileWriter.write(blob);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.log('Failed to get window');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
if (!this.isImage()) {
|
if (!this.isImage()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue