Directus icon

Directus

Consume Directus API

Overview

The "Update Multiple" operation for the "Files" resource in this Directus node allows users to update multiple file records at once by sending a batch PATCH request to the Directus API. This is useful when you want to modify properties (such as tags, metadata, or other attributes) of several files simultaneously without making individual update calls for each file.

Common scenarios:

  • Tagging multiple files with the same category or label.
  • Updating metadata fields across a set of files in bulk.
  • Changing status or custom properties on many files efficiently.

Practical example:
You have a collection of image files and want to add the tag "cities" to all files with specific IDs. Instead of updating each file one by one, you provide an array of file keys and the data object containing the new tags, and the node updates them all in one API call.


Properties

Name Meaning
Update Data (JSON) A JSON object containing two main parts:
- keys: An array of primary keys (IDs) of the files to update.
- data: An object with any of the file object's properties to update (e.g., tags, metadata).

Example value for "Update Data (JSON)":

{
  "keys": ["b6123925-2fc0-4a30-9d86-863eafc0a6e7", "d17c10aa-0bad-4864-9296-84f522c753e5"],
  "data": {
    "tags": ["cities"]
  }
}

Output

The node outputs the response from the Directus API after attempting to update the specified files. The output is a JSON object representing the result of the batch update operation.

  • The json field contains the updated data or confirmation returned by the API.
  • No binary data output is involved in this operation.

The exact structure depends on the Directus API response but typically includes information about the updated files or success status.


Dependencies

  • Requires a valid connection to a Directus instance via an API key credential or equivalent authentication token configured in n8n.
  • The node uses the Directus REST API endpoint for files (PATCH /files) to perform the batch update.
  • Proper permissions are needed on the Directus side to update files.

Troubleshooting

  • Invalid JSON in Update Data: If the JSON provided in the "Update Data (JSON)" property is malformed, the node will throw a parsing error. Ensure the JSON syntax is correct.
  • Missing or incorrect keys: If the keys array is empty or contains invalid file IDs, the API may return errors or no files will be updated.
  • Insufficient permissions: If the API credentials do not have permission to update files, the API will respond with an authorization error.
  • Network or API errors: Connection issues or server errors from the Directus API will cause the node to fail unless "Continue On Fail" is enabled.
  • Data format issues: The data object must conform to the expected schema of the Directus file object properties; otherwise, the API may reject the update.

To resolve errors:

  • Validate JSON input carefully.
  • Confirm that file keys exist and are correct.
  • Check API credentials and permissions.
  • Review Directus API documentation for allowed file properties.

Links and References


This summary covers the static analysis of the "Update Multiple" operation for the "Files" resource based on the provided source code and input property definitions.

Discussion