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 Directus (DrWade) n8n node for the resource Files and operation List allows you to retrieve a list of files from your Directus instance. This operation is highly configurable, supporting advanced filtering, sorting, aggregation, and export options. It is useful in scenarios where you need to:
- Fetch all or a subset of files stored in Directus.
- Apply filters, sorting, or grouping to file queries.
- Export file metadata as CSV, JSON, or XML for reporting or integration purposes.
- Split results into individual items for further processing in n8n workflows.
Practical examples:
- Retrieve all image files uploaded in the last month and process each one individually.
- Export a list of files with specific metadata fields to a CSV file for external analysis.
- Group files by folder and count the number of files per group.
Properties
Name | Type | Meaning |
---|---|---|
Return All | boolean | If enabled, returns all matching files; if disabled, limits the number of returned files according to the "Limit" property. |
Limit | number | Maximum number of files to return (only shown if "Return All" is false). |
Split Into Items | boolean | If enabled, outputs each file as a separate item in the workflow; otherwise, returns an array of files in a single item. |
JSON/RAW Parameters | boolean | If enabled, allows setting query parameters via a raw JSON object instead of the UI fields. |
Query Parameters | json | Custom query parameters as a flat JSON object (used when "JSON/RAW Parameters" is true). |
Additional Fields | collection | Advanced options for querying files, including: - Aggregate: Aggregation functions (count, sum, avg, etc.) on file fields. - Binary Property for Export Data: Name of binary property for exported data. - Deep (JSON): Nested relational query parameters. - Export: Format to export API response (csv, json, xml). - Fields: Specify which file fields to return. - File Name for Export Data: Filename for exported data. - Filter (JSON): Conditions to filter files. - Group By: Field(s) to group results by. - Meta: Metadata to include in the response. - Offset: Number of items to skip. - Search: Search string to match files. - Sort: Sorting order for files. |
Output
- The output is provided in the
json
field of each item. - If Split Into Items is enabled, each file is output as a separate item (
{ json: { ...fileData } }
). - If not, the output is an array of files in a single item (
{ json: [ ... ] }
). - If Export is used, the exported file (CSV, JSON, or XML) is attached as binary data under the specified binary property name, and the
json
field contains the corresponding metadata or summary.
Typical structure of a file object:
{
"id": "string",
"filename_download": "string",
"title": "string",
"type": "string",
"filesize": number,
"storage": "string",
"folder": "string",
"created_on": "string",
"created_by": "string",
...
}
Note: Actual fields depend on your Directus setup and selected "Fields" property.
Dependencies
- Directus API: Requires access to a running Directus instance.
- API Credentials: You must configure the
directusApi
credentials in n8n. - n8n Environment: No special environment variables are required beyond standard n8n and Directus configuration.
Troubleshooting
Common issues:
- Authentication errors: Ensure your Directus API credentials are correct and have permission to list files.
- Invalid JSON in parameters: When using JSON/RAW Parameters or Filter/Deep fields, ensure the input is valid JSON.
- Empty results: Check your filters and search criteria; overly restrictive conditions may yield no files.
- Export issues: If exporting, verify that the binary property name does not conflict with other nodes and that the format is supported.
Error messages:
"error": "Unexpected token ..."
: Indicates invalid JSON in one of the JSON input fields."error": "Request failed with status code 401"
: Authentication failure; check credentials."error": "Request failed with status code 403"
: Insufficient permissions for the requested operation.