Explore Stored Files icon

Explore Stored Files

Explore files stored in a directory

Overview

This node, named "Explore Stored Files," allows users to list and explore files stored in a specified directory on the file system. It reads the contents of a given directory path and outputs metadata about each file found there. This is useful for workflows that need to process or analyze files already saved on disk, such as batch processing, file auditing, or triggering further actions based on existing files.

Practical examples include:

  • Listing all uploaded files in a server directory to trigger subsequent processing.
  • Auditing file storage by retrieving file sizes and modification dates.
  • Feeding file metadata into other nodes for filtering or conditional logic.

Properties

Name Meaning
Directory Path The full path to the directory where the files are stored. The node will read this directory to list its files.

Output

The node outputs an array of JSON objects, each representing one file in the specified directory. Each object contains the following fields:

  • fileName: The name of the file.
  • filePath: The absolute path to the file.
  • fileMimeType: The MIME type of the file if detectable; otherwise, "unknown".
  • fileSize: The size of the file in bytes.
  • lastModifiedDate: The last modification date/time of the file.

No binary data is output by this node; it only provides metadata about files.

Dependencies

  • Requires access to the local file system where the directory resides.
  • Uses Node.js built-in modules for file system operations (fs) and path handling (path).
  • Relies on a helper function to determine MIME types (imported from a common utility module).

No external API keys or credentials are required.

Troubleshooting

  • Common issue: Directory path does not exist or is inaccessible.

    • Error message: Failed to read directory: <error details>
    • Resolution: Verify that the directory path is correct and that the n8n process has sufficient permissions to read it.
  • Potential problem: If the directory contains a very large number of files, execution might be slow or memory-intensive.

    • Consider filtering or limiting files externally before using this node.
  • MIME type detection fallback: If the MIME type cannot be determined, the node returns "unknown" for that file.

Links and References

Discussion