1

I came across this question NodeJS: Saving a base64-encoded image to disk and only find out that this logic only create/write an IMAGE file from disk. But is there way how to save any file from NodeJS using base64-encoded string? I searched all over google but cannot find a decent solution since the result is always limited to image writing.

In case you need to look at my code:

// Use Buffer for decoded base64 string.
var buffer = new Buffer(decodedBase64String, 'base64');

// I used writeFile and base64 encoding option.
fs.writeFile(fullpath, buffer, 'base64', (err) => {
    // If fails handle error here..
});
Shift 'n Tab
  • 8,808
  • 12
  • 73
  • 117

0 Answers0