How to know actual size of byte buffer`s content in nodejs?

You need byteLength:

var buff = fs.readFileSync(__dirname + '/test.txt');
console.log(Buffer.byteLength(buff));

For node 0.10.21 you can try this:

Update buffer.toSTring() is unsafe, since buffers are meant to store binary data and toString() will attempt to do character encoding translation which will corrupt the binary data.

console.log(buff.toString().length);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)