Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Files → Update

AI-generated

Overview

The Files: Update operation in this n8n node allows you to update an existing file object in a Directus instance. This can include updating the file's metadata or replacing the file's binary content. The node supports both updating only metadata and uploading new binary data for the file.

Common scenarios:

  • Replacing an outdated document or image with a new version while keeping the same file ID.
  • Updating file metadata (such as title, description, tags) without changing the actual file content.
  • Automating file management workflows where files need to be programmatically updated in Directus.

Practical examples:

  • A workflow that receives updated product images and replaces the old images in Directus.
  • A process that updates file descriptions or other metadata based on external triggers or data sources.

Properties

Name Type Meaning
Send Binary Data boolean If true, uploads/replaces the file's binary content. If false, only metadata is updated.
ID string Unique identifier of the file object to update. Required to specify which file to update.
Binary Property string (Required if "Send Binary Data" is true) Name of the binary property containing the file data to upload. For multiple files, comma-separated property names can be provided.
Update Fields collection Additional fields to update on the file object. Contains options such as "File Object (JSON)" for specifying other properties as per Directus file object documentation.

Output

  • The output is a json object representing the updated file object as returned by the Directus API.
  • If binary data was uploaded, the response will still be a JSON representation of the updated file object.
  • No binary output is produced by this operation; all outputs are in JSON format.

Example output:

{
  "id": "0fca80c4-d61c-4404-9fd7-6ba86b64154d",
  "filename_download": "newfile.pdf",
  "title": "Updated File Title",
  "description": "New description",
  // ...other file object fields
}

Dependencies

  • External Service: Requires access to a running Directus instance.
  • Authentication: Needs valid Directus API credentials configured in n8n under the name directusApi.
  • n8n Configuration: If uploading binary data, the input item must contain the specified binary property.

Troubleshooting

Common issues:

  • Missing or invalid file ID: If the "ID" does not correspond to an existing file, the update will fail.
  • Binary property not found: If "Send Binary Data" is true but the specified binary property is missing from the input, the node will throw an error.
  • Invalid JSON in additional fields: If the "File Object (JSON)" field contains malformed JSON, the request will fail.
  • Insufficient permissions: The Directus user associated with the API credentials must have permission to update files.

Error messages and resolutions:

  • "Cannot find binary data for property...": Ensure the input item has the correct binary property and its name matches the "Binary Property" value.
  • "Request failed with status code 404": Check that the file ID exists in Directus.
  • "Invalid JSON": Double-check any JSON input fields for syntax errors.
  • "Permission denied": Verify the API credentials have sufficient rights in Directus.

Links and References

Discussion