Describe the problem/error/question
I am new to n8n and trying to create a workflow to fetch email attachments and upload them to my Google Drive. So far, I can use Email Trigger (IMAP) Node to fetch email from my email account (non-Gmail). The test email has 3 pictures pasted inside the email content and one PDF file as an attachment. I can see the attachments as binary at the output of the IMAP node. I add the Code node after the IMAP node to split the attachment files into individual files using the following javascript. I can see the 1 item at inout and 4 items at output.
const binaryData = $binary;
const items = [];
// Loop through binary keys to extract attachment details
Object.keys(binaryData).forEach(key => {
if (key.startsWith('attachment_')) { // Only process attachment keys
items.push({
json: {
binaryKey: key, // Store the key for processing later
fileName: binaryData[key].fileName, // File name of the attachment
},
binary: {
[key]: binaryData[key], // Preserve binary data for processing
},
});
}
});
return items; // Return items for the next node
However, when I added the Google Drive Upload file node at the Code node, I received the error message as below.
{
“errorMessage”: “The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined”,
“errorDetails”: {},
“n8nDetails”: {
“n8nVersion”: “1.72.1 (Self Hosted)”,
“binaryDataMode”: “default”,
“stackTrace”: [
“TypeError: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined”,
" at Function.from (node:buffer:320:9)“,
" at ExecuteContext.getItemBinaryData (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Drive/v2/helpers/utils.js:44:30)”,
" at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Drive/v2/actions/file/upload.operation.js:66:104)“,
" at ExecuteContext.router (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Drive/v2/actions/router.js:58:83)”,
" at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Drive/v2/GoogleDriveV2.node.js:16:38)“,
" at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:741:42)”,
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:724:66",
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1155:20"
]
}
}
Sorry, I cannot share my workflow coz I am using a self-hosted n8n docker version. Hope the below-attached screenshots help you understand my issue and any constructive suggestion is very much welcome. Thank you very much for your time and support in advance.
Information on your n8n setup
- **n8n version:**1.72.1
- **Database (default: SQLite):**Postgres
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- **Running n8n via (Docker, npm, n8n cloud, desktop app):**Docker self-hsot
- Operating system: macOS (M2 Pro chip)