Answers for "nodejs write file from buffer"

0

nodejs write raw buffer to file

/*
	Using nodejs' fs module you can create a WriteStream
    to handle raw stream of bytes and buffers.
*/

const path = "path/to/the/file";

array = BigInt64Array(0);
buffer = Buffer.from(array.buffer)

fs.createWriteStream(path).write(buffer);
Posted by: Guest on June-19-2021
1

writefile in node js

// write_stream.js

const fs = require('fs');

let writeStream = fs.createWriteStream('secret.txt');

// write some data with a base64 encoding
writeStream.write('aef35ghhjdk74hja83ksnfjk888sfsf', 'base64');

// the finish event is emitted when all data has been flushed from the stream
writeStream.on('finish', () => {
    console.log('wrote all data to file');
});

// close the stream
writeStream.end();
Posted by: Guest on March-15-2020
0

write buffer to file in node

fs = require('fs');
fs.writeFile('helloworld.txt', 'Hello World!', function (err) {
  if (err) return console.log(err);
  console.log('Hello World > helloworld.txt');
});
Posted by: Guest on April-19-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language