I have a base64 string of audio file. I want to save this as a file in local folder with nodejs. I have integrated and done this with the fs library and got mp3 file in local folder, but not able to play. Could you please support me to solve this issue. here is my code in nodejs.
let base64File = 'data:audio/mp3;base64,UklGRiRAHwBXQVZFZm10IBAAAAABAAIAgLsAAAD...........';
const DIR = BASE_PATH + 'src/storage/voice/';
const filename = 'sample.mp3';
const fileurl = DIR + filetname;
const fileContents = Buffer.from(base64File, 'base64');
fs.writeFile(fileurl, fileContents, (err) => {
if (err) return console.error(err);
console.log('file saved to ', filetname);
});