I have constructed a file from base64 and I want to save it to the local system
dataURLtoFile(dataurl, filename, format) {
const arr = dataurl.split(',');
const mime = arr[0].match(/:(.*?);/)[1];
const bstr = atob(arr[1]);
let n = bstr.length;
const u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], filename, {type: format});
}
Using this function I can convert my base64 to File. But I want to download this to my local system. How can I do this in angular 2 and above?