Created
March 28, 2019 15:24
-
-
Save Rotron/eb2fdac7cb9a2f1c6437692c5ead4556 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