cschuff cschuff - 1 year ago 291
Node.js Question

Node.js: How to create file with 755 permissions with fs.createWriteStream

Which flag do I need to use in Nodes

to make it create files with 755 permissions.

Answer Source

You can set permissions with createWriteStream, using the mode option:

var fs = require('fs');

var stream = fs.createWriteStream('hello.js', { mode: 0o755 });
stream.write("console.log('hello world');");

This will create a file called hello.js with the mode set to 755 permissions.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download