1var base64Data = req.rawBody.replace(/^data:image\/png;base64,/, "");
2
3require("fs").writeFile("out.png", base64Data, 'base64', function(err) {
4 console.log(err);
5});
1var fs = require('fs');
2
3var imageAsBase64 = fs.readFileSync('./your-image.png', 'base64');
4
1const fs = require('fs');
2const contents = fs.readFileSync('/path/to/file.jpg', {encoding: 'base64'});
3
1const fs = require('fs').promises;
2const contents = await fs.readFile('/path/to/file.jpg', {encoding: 'base64'});
3