It looks like you have a line representing the body of your file.
You just need to make a new buffer with it.
var fileBuffer = new Buffer(file)
If your encoding is not utf8
, you can specify an alternate encoding of the second optional argument.
var fileBuffer = new Buffer(file, 'base64')
If the file is on disk, this is even easier, because by default the operation fs.readFile
returns a buffer.
fs.readFile(file, function(err, buffer){})
tkone source
share