Actions100
- Activity Actions
- Assets Actions
- Authentication Actions
- Collections Actions
- Extensions Actions
- Fields Actions
- Files Actions
- Folders Actions
- Items Actions
- Permissions Actions
- Presets Actions
- Relations Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
Overview
The Assets → Get operation in this n8n node retrieves a specific asset (file) from a Directus instance by its ID. It allows you to fetch metadata about the asset and, optionally, include the actual file data as binary output. This is useful for automating workflows that need to access or process files stored in Directus, such as downloading images, documents, or other media assets for further processing, backup, or integration with other systems.
Practical examples:
- Downloading an image from Directus to send via email.
- Fetching a document to upload to another service.
- Retrieving asset metadata for reporting or auditing purposes.
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 available in the output. Default is "data". Required. |
JSON/RAW Parameters | boolean | If true, query parameters are provided as raw JSON; if false, use the UI fields for additional options. Required. |
Query Parameters | json | Additional query parameters as a flat JSON object. Only shown if "JSON/RAW Parameters" is true. |
Additional Fields | collection | Extra options for thumbnail generation and asset transformation (e.g., fit, format, height, width, quality, transforms, etc.). Only shown if "JSON/RAW Parameters" is false. |
Additional Fields options include:
- Fit: How the thumbnail fits within dimensions (contain, cover, inside, outside).
- Format: Output file format (jpg, png, tiff, webp).
- Height/Width: Dimensions for the thumbnail.
- Key: Asset size key from settings.
- Quality: Image quality (1–100).
- Transforms (JSON): Array of image transformations.
- Without Enlargement: Prevents upscaling of images.
Output
- json: Contains the asset's metadata as returned by Directus. If
Include File Data
is enabled, thejson.file
field contains information about the file. - binary (optional): If
Include File Data
is enabled, the actual file data is included under the property specified by "Binary Property" (default:data
). This can be used in downstream nodes for file operations.
Example output structure:
{
"json": {
"id": "abc123",
"title": "Sample Image",
"description": "...",
"file": {
"id": "abc123",
"filename_download": "image.jpg",
"type": "image/jpeg",
...
},
...
},
"binary": {
"data": {
"data": "<Buffer ...>",
"fileName": "image.jpg",
"mimeType": "image/jpeg"
}
}
}
If Include File Data
is not enabled, the binary
property is omitted and the json.file
field may be removed from the output.
Dependencies
- Directus API: Requires a valid Directus instance accessible via HTTP(S).
- API Credentials: You must configure the
directusApi
credentials in n8n for authentication. - Environment: No special environment variables required beyond standard n8n configuration.
Troubleshooting
Common issues:
- Invalid ID: If the provided asset ID does not exist, the node will throw an error indicating the asset was not found.
- Missing Credentials: If the Directus API credentials are not set up or are invalid, authentication errors will occur.
- Binary Property Name Mismatch: If you specify a custom binary property name, ensure it matches what downstream nodes expect.
- Malformed JSON in Query Parameters or Transforms: If you provide invalid JSON, parsing errors will occur.
Error messages and resolutions:
"Cannot read property 'file' of undefined"
: Likely due to missing or incorrect asset ID, orInclude File Data
is enabled but the asset has no file."Unexpected token ... in JSON"
: Check your JSON input in "Query Parameters" or "Transforms"."401 Unauthorized"
: Check your Directus API credentials.