Created
December 30, 2019 07:17
-
-
Save bonnak/305fe2fc7846352767331257bd13d5b8 to your computer and use it in GitHub Desktop.
Write buffer to file nodejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var crypto = require('crypto'); | |
| var fs = require('fs'); | |
| var wstream = fs.createWriteStream('myBinaryFile'); | |
| // creates random Buffer of 100 bytes | |
| var buffer = crypto.randomBytes(100); | |
| wstream.write(buffer); | |
| // create another Buffer of 100 bytes and write | |
| wstream.write(crypto.randomBytes(100)); | |
| wstream.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment