Directus icon

Directus

Consume Directus API

Overview

The Directus Asset Get operation retrieves detailed information about a specific asset (file) from a Directus instance, with the option to include the actual file data as binary output. This node is useful when you need to fetch metadata or download files stored in Directus, such as images, documents, or other media assets.

Common scenarios:

  • Downloading an image or document from Directus for further processing.
  • Retrieving asset metadata (e.g., dimensions, format, size) for reporting or automation.
  • Fetching and transforming thumbnails or previews of assets.

Practical examples:

  • Automating the download of user-uploaded files for backup or analysis.
  • Generating resized or reformatted thumbnails for use in other systems.
  • Integrating Directus-stored assets into external workflows or applications.

Properties

Name Type Meaning
ID String The unique identifier of the asset (file) to retrieve. Required.
Include File Data Boolean If enabled, the actual file data will be included in the output as binary. If disabled, only metadata is returned. Required.
Binary Property String The name of the binary property under which the file data will be attached in the output. Default is "data".
JSON/RAW Parameters Boolean If enabled, query parameters are provided as raw JSON; otherwise, they are set via UI fields. Required.
Query Parameters JSON Additional query parameters as a flat JSON object. Only shown if "JSON/RAW Parameters" is enabled.
Additional Fields Collection Optional fields to control thumbnail generation and output formatting:
- Fit: How the thumbnail fits within the specified dimensions.
- Format: Output file format.
- Height/Width: Thumbnail size in pixels.
- Key: Predefined asset size key.
- Quality: Image quality (1–100).
- Transforms (JSON): Array of image transformations.
- Without Enlargement: Prevents upscaling.

Output

  • json:
    • Contains the asset's metadata, such as file name, type, size, dimensions, and other properties as provided by Directus.
    • If Include File Data is enabled, the output will also contain a binary field:
      • [Binary Property Name]: The actual file data (e.g., image, PDF) as a binary buffer, suitable for downstream nodes that process files.

Example output structure:

{
  "json": {
    "id": "abc123",
    "title": "Sample Image",
    "type": "image/jpeg",
    "width": 800,
    "height": 600,
    // ...other metadata fields...
    "file": { /* present only if Include File Data is true */ }
  },
  "binary": {
    "data": { /* binary file data, property name configurable */ }
  }
}

If Include File Data is not enabled, the file property is removed from the output.


Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure Directus API credentials (directusApi) in n8n.
  • Environment: No special environment variables required beyond standard n8n credential setup.

Troubleshooting

Common issues:

  • Invalid Asset ID: If the provided ID does not exist, the node will throw an error indicating the asset was not found.
  • Missing Credentials: If Directus API credentials are not configured, the node will fail to connect.
  • Permission Denied: If the API user lacks permission to access the asset, an authorization error will occur.
  • Malformed Query Parameters: If using JSON/RAW mode, ensure the JSON is valid; otherwise, parsing errors may occur.
  • Binary Output Issues: If Include File Data is enabled but the asset is not a downloadable file, the binary output may be empty or missing.

Error messages and resolutions:

  • "Asset not found": Check the ID and ensure the asset exists in Directus.
  • "Invalid credentials": Verify your Directus API credentials in n8n.
  • "Failed to parse JSON": Double-check any JSON input for syntax errors.
  • "No file data available": Ensure the asset actually has associated file data and that Include File Data is enabled.

Links and References

Discussion