Node-Red save to local file [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
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:
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.

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.

Related

How to edit underlying xml files of a .docx archive? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 days ago.
Improve this question
Basically I need to generate dynamic .docx files at runtime. I initially wanted to generate them on the client side to lighten the server workload, since all the necessary data is on the client side. But to simplify the problem, I decided at first to do everything on the server side with Node.JS.
My first attempt was to use docx.js to create the document from scratch before sending it to the client to download. This part is simple and works fine, but the problem is that I have to create more than 10 templates that are quite complicated in design. I was thinking of uploading a document via docx.js to modify it afterwards but this library does not allow to do that.
Then I opened a .docx file and I realized that its underlying structure was an archive containing several XML files, including a document.xml which seems at first sight to contain the text of my document.
So I had the idea to create via OpenOffice or other my templates, and to write functions on my server to open these archives, to modify the values of the document.xml file and to reformat the .docx archive and send it using response.setHeader("Content-type", "application/vnd.openxmlformats-officedocument.wordprocessingml.document") and response.end(blob, "binary").
Any ideas on how I could edit the underlying .xml files in the .docx archive?

Reading a JSON file to edit [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I was given a JSON file and told to read it to get a better understanding of how JavaScript programming works and edit this file to do what I need it to do. It's supposed to be a file to run some cleaning processes on client computers, so I just need to edit it so that they file will run all the processes I want it to run without having to send multiple commands to the computer through my RMM.
When I open the file however in Sublime Text 3 it looks like this. How do I get it to read as JavaScript programming language so I can edit it?
{"os":3,"procedure_type":1,"name":"Clear_PrinterSpool_DNSCache_EventLogs","description":"","version":"2.0","payload":"cX8e1mZa4ffL5OfFuWnR+cqMYnnhpC5Myt22X+nx5dMeS1BYFK5yLlxTPWDPMiw3c0XnZD7Y5zrPIRD9EIxuYLEAa3MYYHZVHhfIUb5MeDifqw3+FHhA/IjFcyL9eSzJ/Nmt2TLu5bPSTQkzqBT9GAdiL0YsDxqn8mpttL0mDCa0g5gJ0vfI41lynD0L8pma6dQ5b3+I+JhSq9irNcHMRrhUkL8dfRUrzIasT/s0q0Ksy0jVu/lcMH+ab0CFlxRMB3aP5dZkBkjTPa4n54pX8yOHejnTbi0qXxVJSBLmFeV4Usw8f/dzbzdR+NN/qSaLP2JU4GXdHjgAIwk0Xb09oFbOhJIu4r7rPku0zLcaq5YXufXXWgzHmBo0AFg1xkGztsfA639dlxZXECxVx4ykMJWnFGl4nowGqsflHSddA4/Q72Nr0ZUm0nM2VAyBhQe8HZ2Z1FwRdBzM8i/YsC6LTGXXjgnn0xin/W2+y+7P+t4n0UFFFAaRT68GuvA/IuwuRjNEIfwhRo5s+qf5D9N1Rbxb/+dvzVVIuwrUIa8HZFHLJM1m4NURNCOTI3aW2o+Qigeah2AOVK4i/mIo94GJ4cnm4odFlli70R8XuKVFzNuKAHfn/TvMorlTdeWaYlLGB67EMtVvGEgSDPCk0mSJkWMzzHm+bxZo+LIAAspBjZuivP68kSm+2FKpMWqlmlKvlx9M+oy+P0koePHx3Ndi4p+Lsm9/mgHyvp3ZdfgmPuMdzOvrMlcibzdAi6e+TohtcQIJpk/yk5OIHgTysbSahwACiwaSLwqLh4SfcQRmmBAn8GoIA+PyD4g3zyErJmaJo6HcpJUcH0g7ytV/rotVvpr+2zW49fPRnCcm8q5pt12qROby42bLUMp/rm03EM+MUKB6I+YzWHENm8tg/O7UDanCyz7DIBbDl4hob8KtL7PA0QDjd9KQ61l/Ld7fNQ9vjNDD+uVaGyDim1ANhwdPMX/nJmvKmVc37XOgEd0AsmicZ8W2FobZpM3yfAdxD3to52N9fwC7T9exYE50RG7+McS+mtd8BRicXe5QfSH5P12GDM9+LaaUVdKzm63FZzhyX/0xpGN97q1VNKPAa6CfO5D/LD21mCrrPeOCeYJ2lHtTo7cW2iu7AXx0WRusz9PX162D+eqeo/ZFmflQv4MpMxnc00pT+QRxX3YZhX/50YU=","payloadChecksum":"d80877609ce0b19f6dcbe3c35d57cd03"}
You can just create a backend call, the URL being pointed to the location of this JSON file.
In the result of that backend call, you will get the contents of the JSON file.

Saving all javascript code in an online database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am really new to making an async game and I would like to know if you could just get the current gamestate and save it as it is or if I would have to grab all code seperatly and organising them into tables. It would be very useful if there was some kind of function that could save everything at once as I am building a pretty big game and it would take a long time grabbing every last piece of information.
So to summarise: I would like to grab the existing gamestate and put everything in a database, then grab everything again and restore that gamestate.
Thanks in advance!
You'll need to submit (or retrieve) the gamestate data to a server with JavaScript. You can use something like JQuery's ajax function for this.
For the server to do anything meaningful with your data, you'll need to use some kind of scripting language. PHP or Node.JS might be a good place to start if you're new to this.
Once the server gets the HTTP request, you can have it send a query to your database (like MySQL) and send back some kind of response.

RESTful Commit to Github file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I've been looking for quite some time if it is even possible to do this.
I'd like to make a RESTful POST call with a javascript without the use of a server (node) to send a json object in the request body to update a json file in a github repo triggering a commit/push.
Yes, it's possible to do this using the Github API.
The URL must be something like that:
https://api.github.com/repos/{repositoryName}/contents/{path}
repositoryName is the repository where you want to put your file and path its path within this repository.
Regarding the authentication, you need to follow this link https://developer.github.com/v3/#authentication. I successfully tested with basic auth.
You need then to use an HTTP method PUT with content with the following structure:
{
"message": "a commit message",
"content": "bXkgbmV3IGZpbGUgY29udGVudHM="
}
The field content corresponds to the content of your file encoded with base 64.
Hope it helps.
Thierry

create PDF file in JS [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am developing a web application using client side MVC. The technology stack is Backbone JS, HTML5 and Spring at the Server side.
I have a requirement where I do some data manipulation at the client side using Javascript by using JSON files as the data payload kept on the web server directly. This is a high traffic part of the app and I don't want to hit my app server for such siple data manipulations.
Now on the same module - I have a requirement where I need to generate a PDF file which effectively contains a static template and then I need to fill the template using effectively the same data that I already have at client side. I need to generate the PDF and let the user download it.
Any idea how can I acheive it completely at the client side in a clean and robust way.
From what I understand is you have an html template that you want to fill with certain data and then render it as a pdf?
For client side, have tried looking at something like jsPdf (http://parall.ax/products/jspdf)? The html renderer is still in early stages but it seems to work decently.
As Bogdan pointed out, a backend solution is also possible. You could look at pd4ml (http://pd4ml.com/) or even call into something like pandoc (http://johnmacfarlane.net/pandoc/) or even phantomjs (http://phantomjs.org/) to perform the conversion and then pass the generated pdf back to the client.
If it is not an html template, I am sure a number of the above solution should work regardless.

Categories

Resources