Directus icon

Directus

Consume Directus API

Overview

This node integrates with the Directus API to update file objects within a Directus-managed system. It allows users to modify metadata or replace the content of existing files by specifying the file's unique ID. The node supports updating files either by sending new binary data (e.g., uploading a new file) or by updating JSON metadata fields associated with the file.

Common scenarios where this node is beneficial include:

  • Updating file metadata such as title, description, or tags without changing the actual file content.
  • Replacing an existing file with a new version by uploading new binary data.
  • Automating file management workflows in Directus, such as batch updating file properties or refreshing file contents programmatically.

Practical example:

  • A user wants to update the description and replace the image file for a product photo stored in Directus. They provide the file ID, set "Send Binary Data" to true, specify the binary property containing the new image, and optionally update metadata fields like description.

Properties

Name Meaning
Send Binary Data Boolean option to choose whether to upload/create a new file content. If true, the node uploads binary data from the specified binary property; if false, it updates only metadata fields.
ID The unique identifier of the file object to update. This is required to specify which file will be updated.
Binary Property (Shown only if "Send Binary Data" is true) The name(s) of the binary property(ies) that contain the file data to be uploaded. Multiple binary properties can be specified separated by commas.
Update Fields A collection of additional fields representing other properties of the file object in JSON format. This allows updating any metadata fields supported by the Directus file object, such as title, description, etc.

Output

The node outputs JSON data representing the updated file object returned by the Directus API after the update operation. The structure corresponds to the Directus file object schema, including updated metadata and file information.

If binary data is sent during the update, the node handles the file upload accordingly but does not output binary data itself; the output remains the JSON representation of the updated file.

Dependencies

  • Requires a valid connection to a Directus instance via an API key credential configured in n8n.
  • The node uses Directus REST API endpoints for files, specifically PATCH requests to files/{id}.
  • For binary uploads, it uses multipart/form-data requests compatible with Directus file upload API.

Troubleshooting

  • Invalid ID error: Ensure the provided file ID exists in the Directus system. Using a non-existent or malformed ID will cause errors.
  • Binary property missing or empty: When "Send Binary Data" is true, verify that the specified binary property exists on the input item and contains valid file data.
  • Malformed JSON in Update Fields: The "File Object (JSON)" field must contain valid JSON. Invalid JSON syntax will cause parsing errors.
  • API authentication errors: Confirm that the API key credential is correctly configured and has sufficient permissions to update files.
  • Network or connectivity issues: Check network access to the Directus instance and ensure the API endpoint is reachable.

Links and References

Discussion