# Setting access rights with \`file out\`

**URL:** <https://discourse.nodered.org/t/setting-access-rights-with-file-out/49705>\
**Category:** General\
**Created:** [14 August 2021 06:45 UTC](https://discourse.nodered.org/t/setting-access-rights-with-file-out/49705 "2021-08-14T06:45:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![augjoh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/augjoh/32/26464_2.png) [@augjoh](https://discourse.nodered.org/u/augjoh)\
**Post date:** [14 August 2021 06:45 UTC](https://discourse.nodered.org/t/setting-access-rights-with-file-out/49705/1 "2021-08-14T06:45:05Z")

</div>

How can I set the access mode (like '0640') when creating files with `file out`?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [14 August 2021 11:34 UTC](https://discourse.nodered.org/t/setting-access-rights-with-file-out/49705/2 "2021-08-14T11:34:13Z")

</div>

I tried a few ways, these two not very elegant options seem to work:

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/3/f38555d0be50494cf28eb35fe3d58a9bacd93d75.jpeg)

```auto
[{"id":"be891798285c7b2b","type":"inject","z":"117fb44a.f7cc54","name":"msg.filename=/home/pi/outputfile1","props":[{"p":"payload"},{"p":"filename","v":"/home/pi/outputfile1","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":190,"y":80,"wires":[["25b5bf7f4935539f","b2f18653481fc387"]]},{"id":"4adf0e528feff296","type":"file","z":"117fb44a.f7cc54","name":"Output to msg.filename","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":570,"y":140,"wires":[[]]},{"id":"25b5bf7f4935539f","type":"exec","z":"117fb44a.f7cc54","command":"umask 0077 && touch","addpay":"filename","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"umask 0077 && touch msg.filename","x":790,"y":80,"wires":[[],[],[]]},{"id":"b2f18653481fc387","type":"delay","z":"117fb44a.f7cc54","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":370,"y":140,"wires":[["4adf0e528feff296"]]},{"id":"c4767db87a366c3b","type":"exec","z":"117fb44a.f7cc54","command":"chmod 642","addpay":"filename","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"chmod 642 msg.filename","x":750,"y":220,"wires":[[],[],[]]},{"id":"5ce0ede37a00953b","type":"inject","z":"117fb44a.f7cc54","name":"msg.filename=/home/pi/outputfile2","props":[{"p":"payload"},{"p":"filename","v":"/home/pi/outputfile2","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":200,"y":220,"wires":[["275dcdcdf654f83f"]]},{"id":"275dcdcdf654f83f","type":"file","z":"117fb44a.f7cc54","name":"Output to msg.filename","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":490,"y":220,"wires":[["c4767db87a366c3b"]]}]

```

---

<div class="post-metadata">

**Author:** ![augjoh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/augjoh/32/26464_2.png) [@augjoh](https://discourse.nodered.org/u/augjoh)\
**Post date:** [21 August 2021 06:31 UTC](https://discourse.nodered.org/t/setting-access-rights-with-file-out/49705/3 "2021-08-21T06:31:21Z")

</div>

Thanks for your sample flows, here. The first seem to fail, when used with temporarily unavailable hard-mounted network file systems, the second exposes the file content to others for a short period of time.

Perhaps the functionality could be added as a property to the `file out`? It is provided from [fs.createWriteStream()](https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [21 August 2021 07:14 UTC](https://discourse.nodered.org/t/setting-access-rights-with-file-out/49705/4 "2021-08-21T07:14:57Z")

</div>

I've added it to the backlog: [Trello](https://trello.com/c/CpsExrVy)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [21 August 2021 07:31 UTC](https://discourse.nodered.org/t/setting-access-rights-with-file-out/49705/5 "2021-08-21T07:31:44Z")

</div>

Surely the ability and scope of the node-red user to set access will be limited by the operating system. Not sure how the ui could cope with just permitted options.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [21 August 2021 07:58 UTC](https://discourse.nodered.org/t/setting-access-rights-with-file-out/49705/6 "2021-08-21T07:58:10Z")

</div>

It would be no different to if the user set a file path to a directory they don't have permission to write to today. The write will fail.

The node won't force the user to specify file permissions - but for a user who knows what they need, they will be able to do so.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 October 2021 07:58 UTC](https://discourse.nodered.org/t/setting-access-rights-with-file-out/49705/7 "2021-10-20T07:58:12Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
