Search code examples
node.jsbase64bufferfilesize

How do I check the size of a file in Node.js?


So, I have a file (jpg, tiff or pdf) which initially is represented as a base64-encoded string, which I create a buffer from.

Now I want to check the size of given file without writing it to filesystem first.

I am using Node v4.4.3 on Linux.

How could I go about doing this?


Solution

  • Use Buffer.byteLength function.