Issue: Google Drive Upload Changes .docx to .zip Despite Correct MIME Type in n8n Workflow
Hello everyone,
I’m encountering an issue in n8n where I’m building a flow to automate uploading documents sent via Telegram into Google Drive. The flow works functionally — the files are uploaded — but there’s a critical inconsistency: files like .docx are being uploaded and saved as ZIP archives in Google Drive instead of as proper Word documents.
Despite setting the correct filename and MIME type, Google Drive seems to ignore or override them.
Flow Breakdown
Here’s the structure of my current n8n workflow:
- Telegram Trigger
User sends a .docx file to the Telegram bot.
Telegram provides file_id and file_name, but the MIME type is usually set to application/octet-stream.
- HTTP Request — Get File Path
https://api.telegram.org/bot/getFile?file_id={{ $(‘Telegram Trigger’).item.json.message.document.file_id }}
- HTTP Request — Download Binary
https://api.telegram.org/file/bot/{{ $json.result.file_path }}
- Code Node — Move and Fix Binary Data
Here’s the code I use to:
Determine the MIME type based on file extension
Move the binary from data to file
Explicitly set fileName and mimeType
const mimeTypesByExtension = {
docx: ‘application/vnd.openxmlformats-officedocument.wordprocessingml.document’,
doc: ‘application/msword’,
pdf: ‘application/pdf’,
// other types omitted for brevity
};
items.forEach(item => {
const filePath = item.json?.result?.file_path || ‘’;
const fileName = filePath.split(‘/’).pop() || ‘’;
const fileExt = fileName.split(‘.’).pop().toLowerCase();
let mimeType = mimeTypesByExtension[fileExt] || ‘application/octet-stream’;
item.json.mimeType = mimeType;
if (item.binary?.data) {
item.binary.file = {
…item.binary.data,
fileName: fileName,
mimeType: mimeType,
};
delete item.binary.data;
}
});
return items;
- Google Drive Node — Upload File
The file uploads to Google Drive successfully. But…
The Problem
In Google Drive, the uploaded file appears as:
Name: document.docx
MimeType: application/x-zip
When opened: Drive treats it as a ZIP file, not a Word document.
Even though:
The .docx file is valid when downloaded directly in n8n (via Write Binary File).
The MIME is explicitly set in the binary object and passed to the Google Drive node.
I’ve tested hardcoding the MIME in the Google Drive node with no success.
this is what I’m getting after uploading