Javascript How to convert Base 64 url to file?
You can use content = new Buffer(content, 'base64')
If you want to save it to a file, you can use this:
/* name is the name of the file you want to save your file in.*/fs.writeFile(name , content, {encoding: 'base64'}, function(err){ if (err) console.log('err', err); console.log('success');});
Try with below hopefully this will work :-
//return a promise that resolves with a File instance function urltoFile(url, filename, mimeType){ return (fetch(url) .then(function(res){return res.arrayBuffer();}) .then(function(buf){return new File([buf], filename,{type:mimeType});}) ); } //Usage example: urltoFile('data:text/plain;base64,aGVsbG8gd29ybGQ=', 'hello.txt','text/plain') .then(function(file){ console.log(file);});