Search code examples
javascripthtmlnode-red

Node-Red save to local file


have looked serveral days now to find a Possibility to save data from my MySQL Database to a local file (on the client PC not the server) to analyze the Data there. I have tried the standard file out node but that only saves to the server File system.

the Flow i am currently using is like this:

current flow

If the Button is clicked the data collected by the Function node is send to the Template node.

The last approach i have found some minutes ago was this: Data URI, but I dont get how to put my msg.payload to the file content.
Sorry for this dumb questions but im barely new to HTML and using it in node-red.

Thanks in advance.


Solution

  • Use the http-in and http-out nodes to create a HTTP endpoint that will return the data you want.

    If you wire the output from the http-in to the input of the database node then the output from the function node to the input on the http-out.

    You can then just point your browser at the URL you configure in the http-in node and the browser should download the data so you can save it locally. You may need to set the Content-Type header to make sure the browser does the right thing with the data.