FileUtils icon

FileUtils

File system operations utility

Read File

AI-generated

Overview

This node operation reads file content from various input sources such as a specified file path, a binary property from an input item, a Base64 property from input item JSON, or a direct Base64 string. It supports outputting the content in different formats including string, Base64, or binary. Additionally, it can compute a digest (hash) of the content using algorithms like MD5, SHA1, SHA256, or SHA512, optionally with a salt, and can output only the digest if desired. This operation is useful for workflows that need to read and process file data from different sources, verify file integrity, or transform file content formats.

Use Case Examples

  1. Reading a file from a given file path and outputting its content as a string.
  2. Reading a binary file from an input item's binary property and outputting it as Base64.
  3. Reading a Base64 encoded string from an input item's JSON property and converting it to binary output.
  4. Computing the SHA256 digest of a file's content with a salt and outputting only the digest.

Properties

Name Meaning
Input Source Selects the source for the file content to read. Options include reading from a file path, a binary property from the input item, a Base64 property from the input item JSON, or a direct Base64 string input.
File Path Path to the file if the input source is 'File Path'. Otherwise, this can provide metadata like filename or type hint for other input sources.
Input Binary Property Name of the binary property in the input item to read data from. Required if the input source is 'Binary Property from Input Item'.
Input Item JSON Property for Base64 Name of the property in the input item JSON data that contains the Base64 encoded string. Required if the input source is 'Base64 Property from Input Item JSON'.
Direct Base64 String Content Paste the Base64 encoded string directly here. Required if the input source is 'Direct Base64 String'.
Output Format Specifies the output format of the file content. Options include auto-detect, string, Base64, or binary.
Digest Algorithm Selects the digest (hash) algorithm to apply to the file content. Options include none, MD5, SHA1, SHA256, and SHA512.
Salt Optional salt value used to increase the security of the digest.
Only Output Digest If selected, only the digest is output instead of the file content.

Output

Binary

When output format is set to binary, the node outputs the file content as binary data in the specified binary property.

JSON

  • content - The file content read from the specified source, formatted according to the output format setting (string, Base64, or binary).
  • digest - The computed digest (hash) of the file content if a digest algorithm is selected.

Dependencies

  • No external dependencies beyond standard file system access and n8n's internal helpers for binary data handling.

Troubleshooting

  • Error 'File Path is required when Input Source is "File Path"' indicates the file path parameter is missing; ensure the file path is provided when reading from a file path.
  • Error 'Input Binary Property name is required when Input Source is "Binary Property from Input Item"' means the binary property name is missing; specify the correct binary property name in the input item.
  • Error 'Input Item JSON Property for Base64 name is required when Input Source is "Base64 Property from Input Item JSON"' means the Base64 JSON property name is missing; provide the correct property name.
  • Error 'Direct Base64 String Content is required when Input Source is "Direct Base64 String"' means the Base64 string content is missing; paste the Base64 string directly in the node.
  • If the output format is set incorrectly, the content may not be usable; choose the appropriate output format based on your workflow needs.
  • Digest computation requires a supported algorithm; selecting 'none' disables digest output.
  • If 'Only Output Digest' is selected, no file content will be output, only the digest.

Discussion