Actions109
- 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
- Webhooks Actions
Overview
The node integrates with the Directus API, a headless CMS and data platform. Specifically, for the Files resource with the Import File operation, it allows users to import a file into Directus by providing a URL from which the file will be downloaded and imported.
This operation is useful when you want to programmatically add files to your Directus-managed media library or file storage without manually uploading them. For example, you might have files hosted on external servers or cloud storage that you want to bring into Directus for further management or use in your projects.
Practical scenarios include:
- Importing images or documents from a remote URL into Directus for use in a website or app.
- Automating bulk imports of assets referenced by URLs.
- Integrating with other systems that provide file URLs, enabling seamless ingestion into Directus.
Properties
| Name | Meaning |
|---|---|
| URL | The URL from which the file will be downloaded and imported into Directus. (Required) |
| Additional Fields | Optional additional properties of the file object in JSON format, allowing customization of the imported file's metadata. |
The Additional Fields property accepts any valid fields defined in the Directus file object schema, enabling users to specify metadata such as title, description, tags, etc., during import.
Output
The output is a JSON object representing the imported file as returned by the Directus API. This typically includes details such as the file ID, filename, URL, size, type, and any metadata associated with the file.
Example output structure (simplified):
{
"id": "file-uuid",
"title": "Example",
"filename_download": "example.jpg",
"type": "image/jpeg",
"url": "/assets/example.jpg",
"metadata": { ... }
}
No binary data is output directly by this operation; the file is imported into Directus and represented as JSON metadata.
Dependencies
- Requires an active connection to a Directus instance via an API key credential or equivalent authentication method.
- The node uses the Directus REST API endpoint
files/importto perform the import. - Proper permissions in Directus are required to upload/import files.
- No additional external dependencies beyond the Directus API and configured credentials.
Troubleshooting
- Invalid URL or inaccessible file: If the provided URL is incorrect, unreachable, or the file cannot be downloaded, the operation will fail. Ensure the URL is publicly accessible or accessible from the environment where n8n runs.
- Authentication errors: If the API credentials are invalid or lack permission to import files, the node will throw an authorization error. Verify API keys and user permissions in Directus.
- Malformed Additional Fields JSON: If the JSON provided in Additional Fields is invalid or contains unsupported properties, the request may fail. Validate JSON syntax and ensure fields conform to Directus file object schema.
- API rate limits or server errors: Network issues or Directus server problems can cause failures. Check connectivity and server health.
Common error messages usually come from the Directus API and should be interpreted accordingly, e.g., 401 Unauthorized, 400 Bad Request, or 404 Not Found.