node.js - How to read binary files in node js -
i trying fetch content of binary file in binary format. think doing wrong. can help?
code sample
var fs = require('fs'); fs.open('public/abc.bin', 'r', function(status, fd) { if (status) { console.log(status.message); return; } var buffer = new buffer(100); fs.read(fd, buffer, 0, 100, 0, function(err, num) { response['msg'] = buffer.tostring('utf-8', 0, num); res.json(response); }); });
Comments
Post a Comment