Way 1: only works for dataURL, not for other types of url.
function dataURLtoFile(dataurl, filename) {_x000D_
_x000D_
var arr = dataurl.split(','),_x000D_
mime = arr[0].match(/:(.*?);/)[1],_x000D_
bstr = atob(arr[1]), _x000D_
n = bstr.length, _x000D_
u8arr = new Uint8Array(n);_x000D_
_x000D_
while(n--){_x000D_
u8arr[n] = bstr.charCodeAt(n);_x000D_
}_x000D_
_x000D_
return new File([u8arr], filename, {type:mime});_x000D_
}_x000D_
_x000D_
//Usage example:_x000D_
var file = dataURLtoFile('data:text/plain;base64,aGVsbG8gd29ybGQ=','hello.txt');_x000D_
console.log(file);
_x000D_
Way 2: works for any type of url, (http url, dataURL, blobURL, etc...)
//return a promise that resolves with a File instance_x000D_
function urltoFile(url, filename, mimeType){_x000D_
return (fetch(url)_x000D_
.then(function(res){return res.arrayBuffer();})_x000D_
.then(function(buf){return new File([buf], filename,{type:mimeType});})_x000D_
);_x000D_
}_x000D_
_x000D_
//Usage example:_x000D_
urltoFile('data:text/plain;base64,aGVsbG8gd29ybGQ=', 'hello.txt','text/plain')_x000D_
.then(function(file){ console.log(file);});
_x000D_