File


The File node reads data from a file and outputs to msg, writes data from msg to a file, or deletes a file.

Node Type

Action.

Input and Output Ability

This node has multiple entry points and 1 exit point.

Node Properties

../../_images/file.png


Name

The name for this node.


Action and File Path

The action, either read from, write to, or delete the file.

  • Read: The data in the file will be output to msg. The name of the file will be output to the metadata. After selecting the action, select either Custom to enter the path of the file manually (expressions can be used) or Default to use the default path. The default path uses the value from ${metadata.files}, which is the value of the files parameter in metadata.
  • Write: The input msg will be written to the file as per the file path. The file must be in the /var folder. If the file exists, the existing content will be overwritten. The name of the file will be output to the metadata.
  • Delete: The file to be deleted must be in the /var folder.


Description

The description for this node.

Limitations

  • Each File node can only read from, write to, or delete 1 file.
  • The file to be deleted must be in the /var folder.

Input and Output Samples

Read

Input

{
    "MetaData": {
        "files": "[\"/tmp/readfile.txt\"]"
    },
    "Body": {
        "assetId":"assetId",
        "timestamp":24214324324,
        "measurepoints":{
            "temperature":22.4,
            "humidity":78
        }
    }
}

Output

{
    "MetaData": {
        "files": "[\"/tmp/readfile.txt\"]"
    },
    "Body": "<note><to>Tony</to>\r\n<from>Jenny</from><heading>Reminder</heading><body>It's okay, when all else fails, reboot!</body></note>"
}

Write

Input

{
    "assetId":"assetId",
    "timestamp":24214324324,
    "measurepoints":{
        "temperature":22.4,
        "humidity":78
    }
}

Output

{
    "MetaData": {
        "files": "[\"/var/data/readfile.txt\"]"
    },
    "Body": {
        "assetId":"assetId",
        "timestamp":24214324324,
        "measurepoints":{
            "temperature":22.4,
            "humidity":78
        }
    }
}

Delete

Input

{
    "assetId":"assetId",
    "timestamp":24214324324,
    "measurepoints":{
        "temperature":22.4,
        "humidity":78
    }
}

Output

{
    "MetaData": {
        "files": "[]"
    },
    "Body": {
        "assetId":"assetId",
        "timestamp":24214324324,
        "measurepoints":{
            "temperature":22.4,
            "humidity":78
        }
    }
}