FileUtils icon

FileUtils

File system operations utility

Overview

The node provides a versatile set of file system operations, with the Read File operation allowing users to read file content from various input sources. It supports reading from:

  • A specified file path on the filesystem.
  • A binary property from an incoming n8n item.
  • A Base64-encoded string property within the input item's JSON.
  • A direct Base64 string entered in the node configuration.

Users can choose how the output is formatted (string, Base64, binary, or auto-detected) and optionally compute cryptographic digests (hashes) of the content using algorithms like MD5, SHA1, SHA256, or SHA512, with optional salting for enhanced security. The node can either output the full content or only the digest.

This operation is beneficial when you need to ingest file data into your workflow from different sources, process it, or verify its integrity via hashing. For example:

  • Reading a local configuration file to use its contents downstream.
  • Extracting binary attachments from previous nodes.
  • Decoding Base64-encoded files stored in JSON properties.
  • Verifying file integrity by generating hashes.

Properties

Name Meaning
Input Source Selects the source of the file content:
- File Path: Read from a specified file path.
- Binary Property from Input Item: Read from a binary property of the input item.
- Base64 Property from Input Item JSON: Read from a Base64 string property in the input JSON.
- Direct Base64 String: Input Base64 string directly in the node.
File Path Path to the file if "Input Source" is "File Path". Optional metadata for other input sources.
Input Binary Property Name of the binary property in the input item to read data from. Required if "Input Source" is "Binary Property from Input Item".
Input Item JSON Property for Base64 Name of the property in the input item JSON that contains the Base64 encoded string. Required if "Input Source" is "Base64 Property from Input Item JSON".
Direct Base64 String Content Paste the Base64 encoded string directly here. Required if "Input Source" is "Direct Base64 String".
Output Format Format of the output content:
- Auto Detect
- String
- Base64
- Binary
Digest Algorithm Optional digest algorithm to compute on the content:
- None
- MD5
- SHA1
- SHA256
- SHA512
Salt Optional salt value to increase digest security. Only applicable if a digest algorithm is selected.
Only Output Digest If enabled, outputs only the computed digest instead of the file content. Only applicable if a digest algorithm is selected.

Output

The node outputs an array of items corresponding to each input item processed. Each output item contains a json field with the following structure depending on options:

  • When no digest is requested or Only Output Digest is false:
    • The file content is returned in the format specified by Output Format:
      • As a string (text).
      • As a Base64 encoded string.
      • As binary data attached to the item.
      • Or auto-detected format.
  • When a digest algorithm is selected and Only Output Digest is true:
    • The output contains only the computed digest string (hexadecimal or base64 depending on implementation).

If binary output is selected, the node attaches the file content as binary data to the output item.

Dependencies

  • Requires access to the local filesystem if reading from a file path.
  • No external API keys or services are required.
  • Uses Node.js built-in crypto libraries for digest computation.
  • No special environment variables needed beyond standard n8n setup.

Troubleshooting

  • Missing Required Parameters: Errors will occur if required parameters for the chosen input source are missing, e.g., no file path provided when reading from file path, or missing binary property name when reading from binary input.
  • Invalid Input Source: Selecting an unsupported input source will throw an error.
  • File Not Found or Access Denied: Reading from a file path may fail if the file does not exist or permissions are insufficient.
  • Malformed Base64 Strings: When reading from Base64 sources, invalid Base64 strings will cause decoding errors.
  • Digest Algorithm Misconfiguration: If a digest algorithm is selected but no content is available, the node may error or produce empty results.
  • To resolve these issues, ensure all required fields are correctly filled, the file paths are accessible, and Base64 strings are valid.

Links and References

Discussion