Directus (denkhaus) icon

Directus (denkhaus)

Consume Directus API

Overview

This n8n node is designed to import a file from a specified URL into a Directus instance. It downloads the file from the provided URL and allows you to attach additional metadata by specifying properties of the file object as defined in the Directus API. This node is useful for automating the process of importing external files (such as images, documents, or other media) directly into your Directus-managed storage.

Common scenarios:

  • Migrating files from an external source into Directus.
  • Automating content ingestion pipelines where files are fetched from URLs and stored in Directus.
  • Enriching imported files with custom metadata during the import process.

Practical example:
You have a list of image URLs and want to batch-import them into Directus, setting titles and descriptions for each image.

Properties

Name Type Meaning
URL String The URL to download the file from. This is the source location of the file to be imported.
Additional Fields Collection Optional extra fields to set on the file object. Allows you to specify any property supported by the Directus file object.
└ File Object (JSON) JSON A JSON object containing properties to set on the imported file (e.g., title, description).

Output

The node outputs a json field representing the result of the file import operation. The structure typically includes details about the imported file, such as its ID, filename, type, and any additional metadata provided. If the file import fails, the output may contain error information.

Example output:

{
  "id": "abc123",
  "filename_download": "example.jpg",
  "type": "image/jpeg",
  "title": "Example",
  // ...other Directus file object properties
}

If binary data is involved (e.g., the raw file), it will be attached as a binary property, representing the downloaded file's contents.

Dependencies

  • Directus API: Requires access to a Directus instance with appropriate permissions to import files.
  • API Key/Authentication: You may need to configure authentication credentials for the Directus API within n8n.
  • Network Access: The n8n instance must be able to reach both the file URL and the Directus API endpoint.

Troubleshooting

  • Invalid URL: If the provided URL is invalid or inaccessible, the node may throw an error indicating a failed download. Ensure the URL is correct and publicly accessible.
  • Authentication Errors: If the Directus API credentials are missing or incorrect, you may see authentication or permission errors.
  • File Object Validation: If the JSON in "File Object (JSON)" is malformed or contains unsupported properties, the node may return a validation error from Directus.
  • Large Files: Importing very large files may fail due to network timeouts or size limits imposed by Directus or n8n.

Links and References

Discussion