Ui-Table download local file


I try unsuccessfully to download a local file using Table.

I managed to do this using httpStatic , like msg.payload[i].Local = "<a href=\"/file.txt\" download=\"file.txt\"> Download File </a>";

I can't do the same thing without using httpStatic.
I tried somethink like : msg.payload[i].Local = "<a href=\"file:///C:\\Temp\\file.txt\">Download File</a>"; , but nothing is happening.

Have you tried just using the "File In" node instead?

How do I do this?

msg.payload[i].Local is an array with tens or even hundreds of values. He only points to a link, which will be accessed optionally. If I put File in, it would mean uploading tens or hundreds of files.

I don't understand what you mean, what is the difference between downloading a file from the local file system using an http download or reading directly with File In node? It is just a different way of reading the same file.

[Edit] Obviously only read in the file if the user clicks on the table to say he wants it.

Simple Flow

[{"id":"436d07b6.730df","type":"tab","label":"Test","disabled":false,"info":""},{"id":"68cddff5.d3496","type":"ui_table","z":"436d07b6.730df","group":"5bf85515.163b74","name":"Test","order":15,"width":"14","height":"2","columns":[{"field":"Link","title":"Link","width":"","align":"left","formatter":"link","formatterParams":{"target":"_blank"}},{"field":"Local","title":"Local File","width":"","align":"left","formatter":"html","formatterParams":{"target":"_blank"}}],"outputs":1,"cts":true,"x":930,"y":240,"wires":[[]]},{"id":"e79d54f8.dfd26","type":"inject","z":"436d07b6.730df","name":"Go","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":510,"y":240,"wires":[["d91d55b4.c8faf"]]},{"id":"d91d55b4.c8faf","type":"function","z":"436d07b6.730df","name":"Rows","func":"msg.payload = [];\n\nvar row1 = {\n    Link : \"http://www.google.com\",\n    Local : \"<a href=\\\"file:///C:\\\\Temp\\\\File_1.txt\\\">File_1</a>\"\n};\n\nmsg.payload.push(row1);\n\n\nvar row2 = {\n    Link : \"http://www.google.com\",\n    Local : \"<a href=\\\"file:///C:\\\\Temp\\\\File_2.txt\\\">File_2</a>\"\n};\n\nmsg.payload.push(row2);\n\n\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":240,"wires":[["68cddff5.d3496","3e3403e8.b7eeec"]]},{"id":"3e3403e8.b7eeec","type":"debug","z":"436d07b6.730df","name":"Rows","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":930,"y":160,"wires":[]},{"id":"5bf85515.163b74","type":"ui_group","z":"","name":"Default","tab":"83b20082.0c1de","disp":true,"width":"14","collapse":false},{"id":"83b20082.0c1de","type":"ui_tab","z":"","name":"Test","icon":"dashboard","disabled":false,"hidden":false}]

When I click on File_1 or File_2 , I need to download the files (from local HDD & Windows OS), without using httpStatic

If you are only downloading from the local device, why do you have links to google?

if you put a debug node of the output of the ui-table node wht do you see when you click one of the items?

Google links ... just example, can be ignored.

topic: "Local"
row: 0
payload:{"Link":"http://www.google.com","Local":"<a href=\"file:///C:\\Temp\\File_1.txt\">File_1</a>"}

So from the debug can you see any way to determine if you clicked on the link or the local file?

If you can, what node could you use to send the message one way if it was link and the other way it if was local?

Why don't you want to use httpStatic?

Colin, I use a lot of files. Some are generated by other applications in various folders. Others come from the local network.

You going to answer my question or are you all set?

zenofmud , please illuminate me with a functional flow. I understand the meaning of your questions, but I got stuck.

I'll illuminate you with probing questions.

Which of the standard nodes do you think you could use to test a value (multiple times) and send the output different ways depending on the result?

I solved this using this example Download a file from node-red using standard nodes from the flows library

Congratulations! (hope you don't mind but I edited your post to show the name of the example and link it for anyone looking at this in the future)

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