Directus icon

Directus

Consume Directus API

Overview

The Directus n8n node, when configured with the File resource and the Get operation, retrieves metadata and details about a specific file stored in a Directus instance. This is useful for workflows that need to fetch information about files (such as images, documents, or other assets) managed by Directus, based on their unique identifier.

Common scenarios:

  • Fetching file details to use in subsequent workflow steps (e.g., sending file info via email, logging, or further processing).
  • Validating file existence or properties before performing actions like download, update, or deletion.
  • Integrating Directus-managed files into external systems or reports.

Example:
You have a file ID from a previous upload or database entry and want to retrieve its metadata (name, type, size, etc.) to display it in a dashboard or send it to another service.


Properties

Name Type Meaning
ID String Unique ID of the file object in Directus. Required to identify which file's details to retrieve.

Output

The output will be a single json object containing the file's metadata as returned by the Directus API. The structure typically includes fields such as:

{
  "id": "0fca80c4-d61c-4404-9fd7-6ba86b64154d",
  "filename_download": "example.pdf",
  "title": "Example File",
  "type": "application/pdf",
  "filesize": 123456,
  "storage": "local",
  "folder": null,
  "uploaded_by": "user-id",
  "uploaded_on": "2023-01-01T12:00:00Z",
  "modified_by": "user-id",
  "modified_on": "2023-01-02T12:00:00Z",
  "charset": null,
  "width": null,
  "height": null,
  "duration": null,
  "embed": null,
  "description": null,
  "location": null,
  "tags": [],
  "metadata": {},
  ...
}

Note: The actual fields depend on your Directus setup and file metadata.

  • No binary data is returned by this operation; only metadata is provided.

Dependencies

  • Directus API: You must have access to a running Directus instance.
  • API Credentials: The node requires valid Directus API credentials (directusApi) configured in n8n.

Troubleshooting

Common issues:

  • Invalid or missing ID: If the provided file ID does not exist, the node will return an error indicating the file was not found.
  • Authentication errors: If the API credentials are incorrect or lack permission to access files, you may receive authentication or authorization errors.
  • Network issues: Connectivity problems between n8n and the Directus server can cause request failures.

Error messages and resolutions:

  • "File not found": Check that the ID is correct and the file exists in Directus.
  • "Unauthorized" or "Forbidden": Ensure your API credentials are valid and have sufficient permissions.
  • "Network Error": Verify network connectivity and Directus server availability.

Links and References


Discussion