# Dowloading a CSV-file via dashboard button

**URL:** <https://discourse.nodered.org/t/dowloading-a-csv-file-via-dashboard-button/10173>\
**Category:** Dashboard\
**Created:** [15 April 2019 13:32 UTC](https://discourse.nodered.org/t/dowloading-a-csv-file-via-dashboard-button/10173 "2019-04-15T13:32:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bjarne](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@Bjarne](https://discourse.nodered.org/u/Bjarne)\
**Post date:** [15 April 2019 13:32 UTC](https://discourse.nodered.org/t/dowloading-a-csv-file-via-dashboard-button/10173/1 "2019-04-15T13:32:07Z")

</div>

Hello

I'm pretty new to Node-red.  
I've already made a program that writes a CSV-file.  
My aim with this project is to display a link to download the file via the dashboard so the end user can download it.  
I've been searching and I think I found a solution but I'm not quiet able to make it work, can someone help me?

This is my flow.

```auto
[{"id":"dca47443.30a3f8","type":"inject","z":"9859d967.3b9e48","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":420,"y":280,"wires":[["751671a3.91b4e8"]]},{"id":"751671a3.91b4e8","type":"function","z":"9859d967.3b9e48","name":"","func":"msg.payload = {};\nmsg.payload = {\"col1\": 1, \"col2\": 2};\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":280,"wires":[["30eb5d75.48c2c2"]]},{"id":"f0b672e0.bf6da8","type":"file","z":"9859d967.3b9e48","name":"TEST.CSV","filename":"~/TEST.CSV","appendNewline":true,"createDir":true,"overwriteFile":"true","x":870,"y":280,"wires":[[]]},{"id":"30eb5d75.48c2c2","type":"csv","z":"9859d967.3b9e48","name":"","sep":",","hdrin":true,"hdrout":true,"multi":"one","ret":"\\n","temp":"col1, col2","x":710,"y":280,"wires":[["f0b672e0.bf6da8"]]},{"id":"d035f2b5.848638","type":"http in","z":"9859d967.3b9e48","name":"downloads","url":"/downloads","method":"get","upload":false,"swaggerDoc":"","x":420,"y":340,"wires":[["f89d269b.ff39e","6315085a.802eb8"]]},{"id":"f89d269b.ff39e","type":"debug","z":"9859d967.3b9e48","name":"","active":true,"console":"false","complete":"false","x":440,"y":420,"wires":[]},{"id":"d27c7676.bf2ab8","type":"http response","z":"9859d967.3b9e48","name":"response","statusCode":"200","headers":{"content-type":"text/plain"},"x":860,"y":340,"wires":[]},{"id":"6315085a.802eb8","type":"ui_template","z":"9859d967.3b9e48","group":"935d095d.aca9d","name":"","order":0,"width":0,"height":0,"format":"<div ng-bind-html=\"msg.payload\"></div>\n<a href=\"~/TEST.CSV\">Download TEST.CSV</a>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":720,"y":340,"wires":[["d27c7676.bf2ab8"]]},{"id":"935d095d.aca9d","type":"ui_group","z":"","name":"Data Export","tab":"3d7e03a4.b27b1c","disp":true,"width":"12"},{"id":"3d7e03a4.b27b1c","type":"ui_tab","z":"","name":"Dashboard","icon":"dashboard","order":1}]

```

I've already changed in the settings.js the httpStatic to: httpStatic: '/home/pi/~'

Furthermore: When I try to download it I receive this screen:

 ![39](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/45257f5d5913bb1adf64692c238976cfb4ae6f67.png)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [15 April 2019 13:48 UTC](https://discourse.nodered.org/t/dowloading-a-csv-file-via-dashboard-button/10173/2 "2019-04-15T13:48:41Z")

</div>

You would need to put your csv file somewhere where the http server has access. Checkout the settings for httpstatic in your settings.js (and in the docs)

Also i would suggest not using ~ in the name

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [15 April 2019 14:00 UTC](https://discourse.nodered.org/t/dowloading-a-csv-file-via-dashboard-button/10173/3 "2019-04-15T14:00:54Z")

</div>

Your flow is not importable - please read: [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![Bjarne](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@Bjarne](https://discourse.nodered.org/u/Bjarne)\
**Post date:** [15 April 2019 14:15 UTC](https://discourse.nodered.org/t/dowloading-a-csv-file-via-dashboard-button/10173/4 "2019-04-15T14:15:42Z")

</div>

I changed, it hope you can import it now.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [15 April 2019 14:41 UTC](https://discourse.nodered.org/t/dowloading-a-csv-file-via-dashboard-button/10173/5 "2019-04-15T14:41:20Z")

</div>

http static shouldn’t include ~

---

<div class="post-metadata">

**Author:** ![echtelerp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/echtelerp/32/535_2.png) [@echtelerp](https://discourse.nodered.org/u/echtelerp)\
**Post date:** [15 April 2019 17:52 UTC](https://discourse.nodered.org/t/dowloading-a-csv-file-via-dashboard-button/10173/6 "2019-04-15T17:52:34Z")

</div>

I did something similar. Except the button.  
In my case, the csv file lies on a local Share on a machine.  
I solved it with the execute function and smbget [https://www.samba.org/samba/docs/current/man-html/smbget.1.html](https://www.samba.org/samba/docs/current/man-html/smbget.1.html)

Works Fine this way 😉

---

<div class="post-metadata">

**Author:** ![Bjarne](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@Bjarne](https://discourse.nodered.org/u/Bjarne)\
**Post date:** [16 April 2019 06:35 UTC](https://discourse.nodered.org/t/dowloading-a-csv-file-via-dashboard-button/10173/7 "2019-04-16T06:35:18Z")

</div>

Do you have an example of this?

---

<div class="post-metadata">

**Author:** ![helviorubens](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/helviorubens/32/39040_2.png) [@helviorubens](https://discourse.nodered.org/u/helviorubens)\
**Post date:** [19 March 2021 14:27 UTC](https://discourse.nodered.org/t/dowloading-a-csv-file-via-dashboard-button/10173/8 "2021-03-19T14:27:09Z")

</div>

I used this example to download a file using only standard nodes and it worked: [https://flows.nodered.org/flow/db68bd4934cf46f39e6e453a348bc419](https://flows.nodered.org/flow/db68bd4934cf46f39e6e453a348bc419)
