Hello,
i need to make a backup file but dont have any folder access with Node Red.
So i searched for a solution and came up with the idea to manually download the backup file and upload the backupfile per Dashboard.
I can create the *.txt if i use a string like = "this is my content", but i cannot manage to use the payload or a global variabel. in an other usecase its a simple {{whatever}}, but its not working here.
thats the part of the flow:
[{"id":"57c11bc0.c5e24c","type":"http in","z":"a4defdc6.648b4","name":"","url":"/writetest","method":"get","upload":false,"swaggerDoc":"","x":370,"y":880,"wires":[["2bf12a6.07ffe56"]]},{"id":"7e699966.fe154","type":"http response","z":"a4defdc6.648b4","name":"","statusCode":"","headers":{},"x":1010,"y":880,"wires":[]},{"id":"2bf12a6.07ffe56","type":"change","z":"a4defdc6.648b4","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"writetestpaket","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":880,"wires":[["48431356.bd85fc","8fdb2dd6.a7a508"]]},{"id":"48431356.bd85fc","type":"template","z":"a4defdc6.648b4","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!DOCTYPE html>\n<html dir=\"ltr\" lang=\"en-US\">\n <head>\n <meta charset=\"utf-8\" />\n <title>Lieferschein-1</title>\n\n<!--<textarea id=\"textbox\">Type something here</textarea> -->\n<button id=\"create\">Create file</button> \n<a download=\"info.txt\" id=\"downloadlink\" style=\"display: none\">Download</a>\n\n\n \n <style>\n </style>\n\n </head>\n \n \n <body>\n <script>\n//Daten aus dem Payload ziehen \n(function(scope) {\n scope.$watch('msg.payload', function(data) {\n update(data);\n });\n})(scope);\n\n//Update der Payloaddaten\nfunction update(data) {\n theScope.send({payload:data});\n}\n\n\n\n (function () {\n var textFile = null,\n makeTextFile = function (text) {\n var data = new Blob([text], {type: 'text/plain'});\n\n // If we are replacing a previously generated file we need to\n // manually revoke the object URL to avoid memory leaks.\n if (textFile !== null) {\n window.URL.revokeObjectURL(textFile);\n }\n\n textFile = window.URL.createObjectURL(data);\n\n return textFile;\n };\n\n\n var create = document.getElementById('create'),\n textbox = document.getElementById('textbox');\n\n create.addEventListener('click', function () {\n var link = document.getElementById('downloadlink');\n link.href = makeTextFile(data);//textbox.value);\n link.style.display = 'block';\n }, false);\n })();\n \n </script>\n </body>\n \n</html>\n","output":"str","x":840,"y":880,"wires":[["7e699966.fe154"]]},{"id":"1a92b9c4.f1de36","type":"ui_button","z":"a4defdc6.648b4","name":"","group":"4d0d29e8.0dce38","order":0,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":350,"y":840,"wires":[["4d05080a.cc587"]]},{"id":"a69b16e4.fdcb5","type":"ui_template","z":"a4defdc6.648b4","group":"4d0d29e8.0dce38","name":"","order":0,"width":"6","height":"6","format":"<div ng-bind-html=\"msg.payload | trusted\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":840,"y":840,"wires":[[]]},{"id":"4d05080a.cc587","type":"template","z":"a4defdc6.648b4","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<iframe src=\"/writetest\" height=70px width=100px ></iframe>","x":540,"y":840,"wires":[["a69b16e4.fdcb5"]]},{"id":"1ac5ce2c.511742","type":"comment","z":"a4defdc6.648b4","name":"Datei erzeugen und download","info":"","x":420,"y":800,"wires":[]},{"id":"8fdb2dd6.a7a508","type":"debug","z":"a4defdc6.648b4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":920,"wires":[]},{"id":"4d0d29e8.0dce38","type":"ui_group","name":"Group 1","tab":"17c3cafa.c3d2cd","order":1,"disp":true,"width":6},{"id":"17c3cafa.c3d2cd","type":"ui_tab","z":"","name":"Dateiverwaltung","icon":"dashboard","order":24,"disabled":false,"hidden":false}]
the interesting part is in the second template node :
link.href = makeTextFile(data);
i would like to have a payload or a global variable on the "data" position.
I hope somebody can help me with that, i am not good with html..
Dearly
Chorum