Quick tip: writing files in node.js

The quick and dirty way is:

but of course you can use also:

You need to wait for the callback to ensure that the buffer is written to disk. It’s not buffered.

All data must be stored at the same time; you cannot perform sequential writes.

Creates a WriteStream, which is convenient because you don’t need to wait for a callback. But again, it’s not buffered.

Leave a Reply