We create a temporary <a href="uri" target="_blank" download="filename" />
element using Javascript, append it to document.body
and then trigger elemnt.click()
.
function downloadURI(uri, name) {
const link = document.createElement("a");
link.href = uri;
link.download = name || uri.split('/').pop();
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
see https://stackoverflow.com/questions/3916191/download-data-url-file