How to download a file from dashboard

Hi

I want to be able to download a file from remote computer, using my node-red dashboard. specifically, I want to click a button on the dashboard that then generates a CSV file from my database and then download it. I have seen some solutions where people use hyperlinks and http nodes to do this. As far as I can see through, all those solutions require you to hardcode a specific hyperlink with a specific file name. I want to be able to download the file I just created and thus need to specify the file name on the fly from the code. I would appreciate any ideas on how I can do this.

you could easily adapt this

Replace the file node with your CSV generating code then pass it back to the endpoint.

Hi, Thanks for your reply.

I thought about that, but it still requires the use of a hyperlink to start off the http request. I would like to start the process with a button click. So I guess I need a way to activate a hyperlink with a button press. is there any way for me to do that?

You can style any hyperlink to look identical to a button.

lots of info

Another option is the use the "httpStatic" url setting to serve any files that exist in a public directory:

    // When httpAdminRoot is used to move the UI to a different root path, the
    // following property can be used to identify a directory of static content
    // that should be served at http://localhost:1880/.
    httpStatic: '/opt/nodered/public/',

The dashboard can then show a list of files that exist in the public directory, and clicking on them should try to either display or download the files contents (depending on the file extension).