Dowload a file using a button - connection lost


#1

Hello together,
I would like to download a csv-file via the nodered dashboard.
I found verry usefull posts in this forum and now it works! But if I hit the download button, the dashboard looses connection and the web page is loaded again. Is this normal for this appilcation or is there a problem?
Another Question is, i would like to use a normal dashborad button and not an html-template-button. Is this possible? if yes, how can i do this?

thank you and best regards
Florian


#2

Sharing your flow will be helpful. I just have a few questions:
Is the browser running on the same machine as NR.
What versions of node-red and node.js?
Which file node are you using?
How big is the file?
Do you see anything on the node-red log?


#3

Hello zenofmud,

here my answers to your quesions:

  • No, my browser is not running on the same machine. My nodered runs on a beagleboneblack (1Ghz) and my browser on a labtop via Cable-Ethernet.
  • The node.js version is the v4.8.7
  • My nodered version is the v0.17.5
  • The file node is a "file in"
  • The file has 17.9 KB
  • What do you mean with the "node-red log"? In the debug-window is no entry.

My flow is:
[{"id":"8a4440e7.4e8e7","type":"http in","z":"69794c24.bda4cc","name":"","url":"/HumiData.csv","method":"get","upload":false,"swaggerDoc":"","x":110,"y":720,"wires":[["4fa2d392.0122bc"]]},{"id":"4fa2d392.0122bc","type":"file in","z":"69794c24.bda4cc","name":"","filename":"/home/debian/HumiData.csv","format":"","sendError":true,"x":360,"y":720,"wires":[["a508bb21.b41978"]]},{"id":"d659f021.5555f8","type":"http response","z":"69794c24.bda4cc","name":"","statusCode":"","headers":{},"x":590,"y":780,"wires":[]},{"id":"a508bb21.b41978","type":"change","z":"69794c24.bda4cc","name":"","rules":[{"t":"set","p":"headers['Content-Disposition']","pt":"msg","to":"attachment; filename=HumiData.csv","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":210,"y":780,"wires":[["d659f021.5555f8"]]},{"id":"66cec20f.09a8e4","type":"ui_template","z":"69794c24.bda4cc","group":"e7c0de75.6d64b","name":"Download HumiData.csv","order":0,"width":0,"height":0,"format":"<form action="/HumiData.csv" method="get">\n <input type="submit" value="Download LogFile" \n name="Submit" id="frm1_submit" />\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":130,"y":660,"wires":[[]]},{"id":"e7c0de75.6d64b","type":"ui_group","z":"","name":"Entfeuchter Chart","tab":"52e9e30f.d04acc","order":2,"disp":true,"width":"6","collapse":false},{"id":"52e9e30f.d04acc","type":"ui_tab","z":"","name":"Entfeuchter","icon":"dashboard","order":4}]


#4

A couple things.

  1. NR version is every old - current version is v0.19.3
  2. node.js is very old and is EOL - current version you should use is v8.x
  3. Your flow will not import, but I hacked it to import it BUT it looks like the template does not have a . Can you open your template, copy the code and insert it in a response - make sure to enclose it with three backtic's

#5

Just tried it with no problems (with template fixed with the </form> added)
Running on a Pi 2 Model B
NR: v0.18.7
node.js: v8.11.2
browser: Safari in OSX 10.13.6
CSV File size: 1M
local network and it flys with no problem.


#6

hello zenofmud,
thank you for your help and testing. Maybe it is a problem of the older versions. At this time i don't want to change anything on my running system :slight_smile:
Maybe if i have more experience with the NR and the linux system i will update NR and node.js. So I will close this thread.

best regards
Florian


#7

[edit] double post.


#8

did you add in the </form>?