File


The File node reads data from one or more files 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. Supports custom path and default path.

    • Custom: Enter the path of the file manually. Supports expressions and the wildcard ? and * to read multiple files. Two or more comma-separated file paths are not supported. After entering, click Search to search the files under the path. You can download the files if required.

      Note

      Viewing and downloading files are only supported when the flow is running.

    • Default: Use the default path. The default path uses the value from ${metadata.files}, which is the value of the files parameter in the metadata of the last node’s outlog.

  • Write: The input msg will be written to the file as per the file path. The file must be in the /var folder. The name of the file will be output to the metadata. Only one file path is supported.

    • Append to Existing File: When writing an input msg to file, enable appending to append the msg to an existing file. If disabled, the msg will overwrite the contents in the file. If the file path does not exist, a new file will be created.
  • Delete: The file to be deleted must be in the /var folder. Supports expressions and the wildcard ? and * to read multiple files. Two or more comma-separated file paths are not supported.


For example, select Read and enter /var/test.txt path. The content of test.txt will be output in the Body. You can click Search and Download to download the test.txt file. If you enter /var/ path, all the files under the /var/ folder can be viewed and downloaded by clicking Search and Download. And the content of all the files will be output in the Body as array formate separated by commas.


Note

Supports reading from the files under the folder /var, /tmp, and /logs only. Files under /tmp and /logs are not supported for writing to or deleting.


Description

The description for this node.

Limitations

  • Each File node can only delete 1 file but can read from and write to multiple files.
  • The file to be wrote and deleted must be in the /var folder.
  • When reading from files, the system will temporarily save the files for viewing and downloading. The files may be deleted later due to file storage time and space.

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
    }
}

Outputs

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