Actions109
- Collections Actions
- Activity Actions
- Assets Actions
- Authentication 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
- Webhooks Actions
Overview
The "Import File Data" operation under the Utilities resource in this custom n8n Directus node allows you to import data from a file (provided as binary input) directly into a specified collection within your Directus instance. This is particularly useful for bulk data imports, migrations, or automating the process of loading external datasets into Directus collections.
Practical scenarios:
- Importing CSV, JSON, or other supported file formats into a Directus collection.
- Automating regular data ingestion from external systems.
- Migrating legacy data into Directus during onboarding.
Properties
| Name | Type | Meaning |
|---|---|---|
| Collection | options | Unique name of the collection to import the data to. Selectable from available collections. |
| Binary Property | string | Name of the binary property where the file is stored in the incoming n8n item. |
Output
- The output will be an object with a
jsonfield containing the result of the import operation. - The structure of the
jsonfield depends on the response from the Directus API after importing the file. Typically, it may include:- Information about the imported items (such as count, IDs, or status).
- If the response is a primitive value (string, number, boolean), it will be wrapped as
{ "result": <value> }. - In case of error and if "Continue On Fail" is enabled, the output will be
{ "error": "<error message>" }.
Example output:
{
"json": {
"imported": 100,
"status": "success"
}
}
or, for a simple result:
{
"json": {
"result": "Import completed"
}
}
Dependencies
- Directus API: Requires access to a running Directus instance.
- API Credentials: You must configure the
directusApicredentials in n8n for authentication. - Binary Data: The file to import must be present as a binary property on the incoming n8n item.
Troubleshooting
- Missing Binary Data: If the specified binary property does not exist or is empty, the import will fail. Ensure the file is correctly attached to the incoming item.
- Invalid Collection Name: If the collection name is incorrect or does not exist in Directus, the operation will fail.
- File Format Issues: If the file format is not supported by Directus or does not match the expected schema, the import may fail or produce partial results.
- Common Error Messages:
"Cannot read properties of undefined (reading 'fileName')": The binary property name is incorrect or missing."Collection not found": The specified collection does not exist in Directus."Invalid file format": The uploaded file cannot be parsed or imported by Directus.
How to resolve:
- Double-check the binary property name and ensure the file is present.
- Verify the collection exists in Directus.
- Confirm the file format matches what Directus expects for import.