Write file to a local disk drive

I am injecting a simple 'Hello' string into a file and want to save the file to my local PC. However, since Node-RED is running on a server, all attempts have resulted in the file being written to the server instead. Is it possible to write the file directly to my local machine?

[
    {
        "id": "8a6ba7b298a5a932",
        "type": "inject",
        "z": "e309c37c879f6a3a",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "Hello, World!",
        "payloadType": "str",
        "x": 190,
        "y": 120,
        "wires": [
            [
                "7827ee46592af7da"
            ]
        ]
    },
    {
        "id": "7827ee46592af7da",
        "type": "file",
        "z": "e309c37c879f6a3a",
        "name": "",
        "filename": "file://C:/Temp/Hello.txt",
        "filenameType": "str",
        "appendNewline": false,
        "createDir": true,
        "overwriteFile": "true",
        "encoding": "none",
        "x": 440,
        "y": 120,
        "wires": [
            [
                "c8afd54ae18fe26b"
            ]
        ]
    },
    {
        "id": "7ab566b3ccbbbe4b",
        "type": "debug",
        "z": "e309c37c879f6a3a",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 970,
        "y": 140,
        "wires": []
    },
    {
        "id": "c8afd54ae18fe26b",
        "type": "file in",
        "z": "e309c37c879f6a3a",
        "name": "",
        "filename": "file://C:/Temp/Hello.txt",
        "filenameType": "str",
        "format": "utf8",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "allProps": false,
        "x": 700,
        "y": 120,
        "wires": [
            [
                "7ab566b3ccbbbe4b"
            ]
        ]
    }
]

One way (and the way I often use) is to use SCP (secure copy protocol) inside an Exec node.

I suggest you do a little research on SCP first (eg What is SCP Protocol? A Complete Guide) to see if it suits your needs.

That is the process of Downloading a file from the server to the PC running the browser. I have not done this myself, but If you search the forum for Download File I expect it will produce a number of possibilities.

The node @prescient-devices/node-red-contrib-downloadfile can accomplish what you desire. You can find it here.

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