File: Read Node
The File: Read Node allows you to read a file from disk in the device’s Gateway Edge Agent. This node is only available in edge workflows.
Configuration
There are five configuration settings for this node:
- File Path: (Required) A string template for the location of the file to read within the container. This must resolve to a path that the agent’s Docker container has permission to read; in most cases this requires mounting a volume into the container.
- Encoding: The file encoding (defaults to UTF-8).
- Start Position: A string template or integer for the byte at which to start reading. Not setting a value defaults to the start of the file. Passing a negative integer will start reading that many bytes from the end of the file.
- Bytes to Read: A string template or integer for the number of bytes to read. Not setting a value reads until the end of the file.
- Result Path: (Required) A payload path for where to store the result of the operation.
Attempting to read a file that is larger than 5MB will result in an error.
Result
In the example above, the workflow will retrieve the contents of the file at the payload path data.fileName
. If the result path is set to data.result
, and the read operation was successful, your output would look like the following:
{
"data": {
"result": {
"bytesRead": 100,
"content": "Some kind of file content that is on your edge machine, maybe a log file, maybe a configuration file..."
}
}
}
If the read was unsuccessful then the output would look like the following:
{
"data": {
"result": {
"error": {
"type": "FILE_READ_ERROR",
"message": "A message describing the reason for the error."
}
}
}
}
Related Nodes
Was this page helpful?
Still looking for help? You can also search the Losant Forums or submit your question there.