Actions100
- Activity Actions
- Asset Actions
- Authentication Actions
- Collection Actions
- Extension Actions
- Field Actions
- File Actions
- Folder Actions
- Item Actions
- Permission Actions
- Preset Actions
- Relation Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
Overview
The Directus - File: Update operation in n8n allows you to update an existing file object in your Directus instance. This can include updating the file's metadata or replacing the file's binary content itself. The node supports both updating only metadata and uploading new binary data for the file.
Common scenarios:
- Replacing a file (e.g., updating a document or image with a new version).
- Updating file metadata such as title, description, tags, or custom fields.
- Automating file management workflows where files need to be programmatically updated based on external triggers.
Practical examples:
- Automatically updating a product image in Directus when a new image is uploaded to another system.
- Changing the metadata of a file after it has been processed by another workflow step.
Properties
Name | Type | Meaning |
---|---|---|
Send Binary Data | boolean | If true, uploads/replaces the file's binary content. If false, only updates file metadata. |
ID | string | Unique identifier of the file object to update. Required to specify which file will be updated. |
Binary Property | string | (Required if "Send Binary Data" is true) Name of the binary property containing the new file data to upload. For multiple files, use comma-separated property names. |
Update Fields | collection | Additional fields to update on the file object. Contains: • File Object (JSON): JSON object with other properties of the Directus file object. |
Output
- The output is a single item with a
json
field containing the updated file object as returned by the Directus API. - If the update was successful, the structure matches the Directus file object, including all standard and custom fields.
- If binary data was uploaded, the response still returns the file object metadata; the binary content itself is not included in the output.
Example output:
{
"id": "0fca80c4-d61c-4404-9fd7-6ba86b64154d",
"filename_download": "newfile.pdf",
"title": "Updated Document",
"description": "This is the updated file.",
"type": "application/pdf",
"filesize": 123456,
"storage": "local",
"uploaded_by": "user_id",
"uploaded_on": "2024-06-01T12:00:00Z",
"...": "other fields"
}
Dependencies
- Directus API: Requires access to a Directus instance.
- API Credentials: You must configure Directus API credentials in n8n under the name
directusApi
. - Binary Data: If uploading a new file, the binary data must be available in the specified binary property.
Troubleshooting
Common issues:
- Missing or invalid ID: If the provided file ID does not exist, the node will return an error from the Directus API.
- Binary property not found: If "Send Binary Data" is enabled but the specified binary property does not exist in the input, the node will throw an error.
- Invalid JSON in Update Fields: If the "File Object (JSON)" field contains malformed JSON, the update will fail.
- Insufficient permissions: The API user must have permission to update files in Directus.
Error messages and resolutions:
"Cannot find binary property"
: Ensure the binary property name matches the one present in the incoming data."Request failed with status code 404"
: Check that the file ID exists in Directus."Invalid JSON"
: Validate the JSON syntax in the "File Object (JSON)" field."Permission denied"
: Verify the API credentials have sufficient rights.