I would like to read a file and convert it into a base64 encoded string using the FileReader object. Here\'s the code I use :
var reader = new FileReader();
To read the contents of a file synchronously use fs.readFileSync
var fs = require('fs'); var content = fs.readFileSync('myfilename'); console.log(content);
fs.createReadStream creates a ReadStream.