Overview
This node modifies the MIME type metadata of a binary file attached to each input item. It is useful when you need to correct or change the MIME type associated with binary data without altering the actual content. For example, if a file was incorrectly labeled as image/jpeg but is actually a PDF, this node can update its MIME type to application/pdf. Additionally, it can optionally update the file extension and filename to match the new MIME type.
Common scenarios include:
- Correcting MIME types after file uploads or downloads.
- Preparing files for systems that rely on accurate MIME types.
- Standardizing file metadata in workflows handling diverse binary data.
Properties
| Name | Meaning |
|---|---|
| Binary Property | Name of the binary property on each item to modify (e.g., "data" or "file"). This specifies which binary field's MIME type will be changed. |
| New MIME Type | The new MIME type string to assign to the binary data (e.g., image/png, application/pdf, text/plain). |
| Also Update File Extension | Whether to update the file extension and filename to correspond with the new MIME type. If enabled, requires specifying the new extension. |
| New Extension | The new file extension (without dot) to apply if updating the file extension (e.g., png, pdf, txt). |
| Filename Handling | How to handle the filename when updating the extension: - Do Not Touch Filename: Leave the filename unchanged. - Smart Replace Extension: Replace existing extension if present; otherwise append. - Force Replace/Append: Always replace or append the extension forcibly. |
| Skip Missing Binary (Do Not Error) | Whether to allow items missing the specified binary property to pass through unchanged instead of throwing an error. Useful for workflows where some items may not have binary data. |
Output
The output consists of the input items with their specified binary property's MIME type updated to the new value. If enabled, the file extension and filename are also updated accordingly.
Each item's binary field contains the modified binary data object with these changes:
mimeType: Updated to the new MIME type.fileExtension: Optionally updated to the new extension.fileName: Optionally updated based on the filename handling setting.- Other binary metadata such as
fileSizeanddirectoryare preserved.
No binary content is altered; only metadata is changed.
Dependencies
- Requires access to the binary data buffer of each item via n8n's helper methods.
- No external API or service dependencies.
- No special environment variables or credentials needed.
Troubleshooting
Error: Item X is missing binary property "Y".
This occurs if an item does not contain the specified binary property and "Skip Missing Binary" is disabled. To fix, either ensure all items have the binary property or enable "Skip Missing Binary" to bypass such items.Error: When "Also Update File Extension" is enabled, "New Extension" must be provided.
This means you enabled extension updating but did not specify the new extension. Provide a valid extension without a leading dot (e.g.,pdf).Incorrect filename updates:
Check the "Filename Handling" option to control how filenames are modified when changing extensions.