# Write msg.payload to a file on my synology NAS

**URL:** <https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753>\
**Category:** General\
**Created:** [17 June 2024 10:02 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753 "2024-06-17T10:02:57Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![sigi3360](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@sigi3360](https://discourse.nodered.org/u/sigi3360)\
**Post date:** [17 June 2024 10:02 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/1 "2024-06-17T10:02:57Z")

</div>

I am running nodered on my Synology NAS.  
I want to write a message (msg.payload) that arrives from a temperature sensor on my nodered server to a csv file on my Synology NAS. I have big problems with the correct formulation of the file path.

Can someone give me an example of how to enter the path?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 June 2024 10:09 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/2 "2024-06-17T10:09:00Z")

</div>

Hi and welcome to the world of `Node-Red`.

When you say write a `csv` file.... Do you mean each value would be written to the end of the file to create a `csv` file?

So, basically:

You get `msg.payload` with the value you want.

You want to write that to a file (appending).

And each entry would be separated by a `,`.

receive `msg.payload`. Put that into a `template` node (the orange one)  
and in the field you would put:  
`, {{payload}}`

You then send that to a `write file` node and set the name of the file.

That's about it.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 June 2024 10:34 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/3 "2024-06-17T10:34:04Z")

</div>

> [@sigi3360](#):
>
> Can someone give me an example of how to enter the path?

Show us the node red startup log, that will tell us about the folder structure you are operating under.

---

<div class="post-metadata">

**Author:** ![sigi3360](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@sigi3360](https://discourse.nodered.org/u/sigi3360)\
**Post date:** [17 June 2024 14:12 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/4 "2024-06-17T14:12:01Z")

</div>

where can i find the startup log or how can i generate it when i run nodered on my synology nas?

---

<div class="post-metadata">

**Author:** ![sigi3360](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@sigi3360](https://discourse.nodered.org/u/sigi3360)\
**Post date:** [17 June 2024 14:13 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/5 "2024-06-17T14:13:24Z")

</div>

my problem is that i don't know exactly how to enter the path to the file if the file is on my NAS. It always says that the file cannot be found.

This is how I entered the path:

\192.168.1.194\volume1\docker\nodered\storage/test1.csv

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 June 2024 14:40 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/6 "2024-06-17T14:40:20Z")

</div>

Assuming that node-red and the file are both on the NAS then you don't need the ip address. However, I see that node red is running in a docker container so you need to enter the path from _inside_ the container. If the place where you want to save it is not directly accessible from inside the container then you will have to mount that folder in the container. Docker is a pain.

If you add an Exec node to the flow and in it put the command  
`pwd`  
and feed that into a debug node, what does it show? Trigger it from an Inject node obviously. That may give us a clue about the file structure.

---

<div class="post-metadata">

**Author:** ![sigi3360](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@sigi3360](https://discourse.nodered.org/u/sigi3360)\
**Post date:** [17 June 2024 15:36 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/7 "2024-06-17T15:36:00Z")

</div>

Thank you for your help!  
This is the output:  
/usr/src/node-red

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/a/fa3f8d48f1c868e3bd5626bf7aa0e2b32dc959ee.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/9/19fce076c4f5a8db2693bfb9fa76522ba48c001b.png)

---

<div class="post-metadata">

**Author:** ![sigi3360](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@sigi3360](https://discourse.nodered.org/u/sigi3360)\
**Post date:** [17 June 2024 19:01 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/8 "2024-06-17T19:01:08Z")

</div>

Unfortunately, even with this information on the file structure, I am still not making any progress.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 June 2024 20:09 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/9 "2024-06-17T20:09:21Z")

</div>

Also unfortunately no-one here (so far) seems to know about the file structure on this device.

Do you need to run node-red there rather than on something more appropriate?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [17 June 2024 21:04 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/10 "2024-06-17T21:04:22Z")

</div>

> [@Colin](#):
>
> Also unfortunately no-one here (so far) seems to know about the file structure on this device.

That isn't true Colin. A number of us have Synology NAS's. We are missing critical information though.

Is Node-RED running in Docker **on the NAS**?

If so, as seems likely, the OP needs to give the Docker Node-RED config access to that location since, by default, it will only have writable access to the `/data` folder (which is another folder somewhere in `volume1` most likely).

Synology NAS's are not full-featured Linux implementations. For example, they only have Busybox and not a full BASH environment. But they do have decent web admin interfaces and it should be easy enough to assign the correct folder to the Node-RED Docker config.

I don't use docker on my NAS because the NAS is rather chock full of files and is primarily used for doing backups from/to cloud. So though it is an Intel processor version, and has upgraded memory, running Docker processes tends to occasionally bring the file and backup handling to a crawl - even without Docker running, I regularly get notifications that the disk I/O is at 99% utilisation. There are a LOT of files and folders. 😀

---

<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:** [17 June 2024 21:36 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/11 "2024-06-17T21:36:56Z")

</div>

This recent thread may be useful [Docker - Node Red - add and access additional volume](https://discourse.nodered.org/t/docker-node-red-add-and-access-additional-volume/88724)?

---

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [18 June 2024 01:53 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/12 "2024-06-18T01:53:54Z")

</div>

Hello @sigi3360 , you will not be able to write/read directly to/from your NAS file.

in [this thread](https://discourse.nodered.org/t/write-node-on-synology-nas/88430/9) i have explained how I map/bind a NAS drive to my docker image, and in [this post](https://discourse.nodered.org/t/write-node-on-synology-nas/88430/7) I have explained how you can read/write to a file on your NAS when mapped

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 June 2024 08:01 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/13 "2024-06-18T08:01:02Z")

</div>

> [@TotallyInformation](#):
>
> > [@Colin](#):
> >
> > Also unfortunately no-one here (so far) seems to know about the file structure on this device.
> 
> That isn't true Colin. A number of us have Synology NAS's. We are missing critical information though.

That is why I said 'so far', meaning that no-one who has seen the post has the knowledge to help, but I think my wording was not clear.

---

<div class="post-metadata">

**Author:** ![sigi3360](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@sigi3360](https://discourse.nodered.org/u/sigi3360)\
**Post date:** [19 June 2024 09:27 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/14 "2024-06-19T09:27:41Z")

</div>

Hello together  
I have come one step further.  
I found out that there is already a drive mapped to my Synology NAS.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a6c133fecaf4ab6a8617deda696885581ed37224.png)

I have placed the csv file in which I want to save my data directly in this folder. I have entered the following path for the node:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/f/6f96939d353ce3476e6b0d050d491af2c73d9817.png)

**The payload is written correctly to the file and looks like this:**  
{"end\_device\_ids":{"device\_id":"eui-a840413aa1844bb6","application\_ids":{"application\_id":"eschenweg11tempkeller"},"dev\_eui":"A840413AA1844BB6","join\_eui":"A840410000000101","dev\_addr":"260B02E0"},"correlation\_ids":["gs:uplink:01J0PGJA1XACWJ8KPYX0VN0W3A"],"received\_at":"2024-06-18T20:28:13.449518301Z","uplink\_message":{"session\_key\_id":"AYLfEYQASCGoMuEcCRCw9w==","f\_port":2,"f\_cnt":190476,"frm\_payload":"DkYAAAEkAAC6AyE=","decoded\_payload":{"batteryV":"3.654","hum\_sht":"80.1","tempc\_sht":"18.60"},"rx\_metadata":[{"gateway\_ids":{"gateway\_id":"loragardener1","eui":"58A0CBFFFE8028ED"},"time":"2024-06-18T20:28:13.108084917Z","timestamp":2115280988,"rssi":-55,"channel\_rssi":-55,"snr":11,"location":{"latitude":47.17489679472269,"longitude":7.554766237735748,"altitude":447,"source":"SOURCE\_REGISTRY"},"uplink\_token":"ChsKGQoNbG9yYWdhcmRlbmVyMRIIWKDL//6AKO0Q3MDS8AcaCwjd28ezBhCI3YF1IODOyYTIjRA=","received\_at":"2024-06-18T20:28:13.221250293Z"}],"settings":{"data\_rate":{"lora":{"bandwidth":125000,"spreading\_factor":7,"coding\_rate":"4/5"}},"frequency":"867700000","timestamp":2115280988,"time":"2024-06-18T20:28:13.108084917Z"},"received\_at":"2024-06-18T20:28:13.246183773Z","consumed\_airtime":"0.061696s","network\_ids":{"net\_id":"000013","ns\_id":"EC656E0000000181","tenant\_id":"ttn","cluster\_id":"eu1","cluster\_address":"eu1.cloud.thethings.network"}}}

Which node do I have to use if I only want to write individual parts of the long payload to my csv file?  
What do I have to enter in the node?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [19 June 2024 09:34 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/15 "2024-06-19T09:34:56Z")

</div>

> [@sigi3360](#):
>
> Which node do I have to use if I only want to write individual parts of the long payload to my csv file?

The only way to do partial updates on files is to APPEND to the end of the file.

If you want to do anything more complex, you will almost certainly need to use something other than a CSV file.

---

<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:** [17 September 2024 09:35 UTC](https://discourse.nodered.org/t/write-msg-payload-to-a-file-on-my-synology-nas/88753/16 "2024-09-17T09:35:10Z")

</div>

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