mirror of
https://github.com/documize/community.git
synced 2025-08-04 21:15:24 +02:00
Better client-side download file process
This commit is contained in:
parent
9d80c5fc8c
commit
82a5bfe198
1 changed files with 12 additions and 10 deletions
|
@ -55,17 +55,19 @@ export default Service.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
downloadFile(content, filename) {
|
downloadFile(content, filename) {
|
||||||
let b = new Blob([content], {
|
let b = new Blob([content], { type: 'text/html' });
|
||||||
type: 'text/html'
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = window.URL.createObjectURL(b);
|
let a = document.createElement("a");
|
||||||
var link = document.createElement('a');
|
a.style = "display: none";
|
||||||
link.href = data;
|
document.body.appendChild(a);
|
||||||
link.download = filename;
|
|
||||||
link.click();
|
|
||||||
|
|
||||||
// For Firefox it is necessary to delay revoking the ObjectURL
|
let url = window.URL.createObjectURL(b);
|
||||||
setTimeout(function() { window.URL.revokeObjectURL(data), 100});
|
|
||||||
|
a.href = url;
|
||||||
|
a.download = filename;
|
||||||
|
a.click();
|
||||||
|
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
document.body.removeChild(a);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue