Directus icon

Directus

Consume Directus API

Overview

The node integrates with the Directus API, providing a wide range of operations across many Directus resources. Specifically, for the Utilities resource and the Import File Data operation, the node allows importing file data into a specified collection within Directus by uploading a binary file.

This operation is useful when you want to programmatically import files (such as CSVs, JSON, images, or other binary data) into a Directus collection, automating data ingestion workflows. For example, you might use this node to import product images or bulk data files into your Directus-managed database from an external source or previous workflow step.

Properties

Name Meaning
Collection The unique name of the Directus collection where the file data will be imported.
Binary Property The name of the binary property in the input data that contains the file to be imported.

Output

  • The output json field contains the response data from the Directus API after attempting to import the file data.
  • The structure typically includes metadata about the imported file or import operation result.
  • If the response is a primitive type (string, number, boolean), it is wrapped inside an object with a result key.
  • The node does not explicitly output binary data for this operation; it focuses on the import result metadata.

Dependencies

  • Requires a valid connection to a Directus instance via an API key credential configured in n8n.
  • The node uses Directus API endpoints to perform the import, specifically a POST request to utils/import/{collection}.
  • The binary file data must be available in the input item under the specified binary property name.
  • No additional external dependencies beyond the Directus API and n8n's built-in helpers for handling binary data.

Troubleshooting

  • Common Issues:

    • Missing or incorrect collection name: Ensure the collection exists in Directus and the name is correctly specified.
    • Binary property not found or empty: Verify that the input item contains the binary data under the exact property name provided.
    • Authentication errors: Confirm that the API key credential is valid and has permissions to import files.
    • File format issues: The imported file should be compatible with the expected format for the target collection.
  • Error Messages:

    • API errors returned from Directus will be propagated. Common messages include unauthorized access, invalid collection, or malformed file data.
    • If the node is set to continue on fail, errors will appear in the output JSON under an error key.
  • Resolution Tips:

    • Double-check collection names and permissions in Directus.
    • Inspect the binary data in previous nodes to ensure it is correctly loaded.
    • Review API credentials and regenerate if necessary.
    • Validate the file format before import.

Links and References


This summary covers the logic and usage of the "Import File Data" operation under the Utilities resource in the Directus node for n8n, based on static analysis of the provided source code and properties.

Discussion