Export data.

This commit is contained in:
HenriT
2021-02-16 17:50:17 +02:00
parent db476ff5b3
commit 0ae8bbce91
3 changed files with 59 additions and 2 deletions

View File

@ -29,3 +29,21 @@ export function pick(obj, map) {
});
return objSubset;
}
export function download(data, filename, type) {
var file = new Blob([data], {type: type});
if (window.navigator.msSaveOrOpenBlob) // IE10+
window.navigator.msSaveOrOpenBlob(file, filename);
else { // Others
var a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
}