Upload multiple attachments from Gmail to Google Drive without
Summary This template uses the item handling nodes, and expression-support in n8n, without using a Code node, to extract multiple attachments from a GMail (t...
🔌 Nodes & Integrations Used (2)
📖 Implementation & Setup Guide
Summary This template uses the item handling nodes, and expression-support in n8n, **without using a `Code` node**, to extract **multiple** attachments from a GMail (trigger input) message/event, and (conditionally) upload each of them to Google Drive.
Note: There is another template titled [Get Multiple Attachments from Gmail and upload them to GDrive](<https://n8n.io/workflows/2348-get-multiple-attachments-from-gmail-and-upload-them-to-gdrive/>) that does basically the same thing, but it uses a `Code` node.
Details ### Using `Split Out` instead of `Code` The “secret” to how this works is that n8n supports a special input field name `$binary` that references the entire set of (multiple) binary data sub-elements in a single input item. It may look like an expression, but in this case it is a “fixed” (literal) value used as the `Fields to Split Out` parameter value.
Dealing with names that are prefixed/suffixed with an Index The next challenge with multiple attachments from a GMail message is that **each one is still assigned different name** like "attachment_0", "attachment_1", etc. This makes it tricky to reference them in a generic way. However, **once n8n splits the items out**, the binary in **each item is always the first (i.e. index-zero / `[0]`) and ONLY key/value**. So, that makes it possible get the key-name and attributes of the corresponding value indirectly with some clever expression syntax. * `Input Data Field Name` -> Expression: `{{ $binary.keys()[0] }}` - **This returns the name, regardless of whether it is "attachment_0", "attachment_1", or whatever else.** * Attachment file name: -> Expression: `{{ $binary.values()[0].fileName }}` * Attachment file name extension: -> Expression: `{{ $binary.values()[0].fileExtension }}` * Attachment file type: -> Expression: `{{ $binary.values()[0].fileType }}` * Attachment file size (e.g. string "100 kB"): -> Expression: `{{ $binary.values()[0].fileSize }}` * Attachment file size (numeric): -> Expression: `{{ $binary.values()[0].fileSize.split(' ')[0].toNumber() }}` * Attachment mime type: -> Expression: `{{ $binary.values()[0].mimeType }}` * Attachment id (storage GUID): -> Expression: `{{ $binary.values()[0].id }}`
Flow Control Since each of the attachments becomes a single item, it is relatively straightforward to introduce other n8n nodes like `If`, `Switch`, or `Filter` and route each single attachment item into different workflow paths. The template demonstrates how each attachment binary could be routed based on its file size, as an example.
⚡ How to import this workflow into n8n:
- Click the Direct Download JSON button above to save
Upload_multiple_attachments_from_Gmail_to_Google_Drive_without.json. - Log in to your n8n Cloud or self-hosted n8n instance.
- In your workflow canvas, click the menu in top-right and select Import from File (or paste the JSON directly).
- Configure your credentials (e.g. API keys, database URLs) in the corresponding node settings.
- Click Execute Workflow to test and switch to Active!
Related Email & Outreach Workflows
View All in Email & Outreach →Abandoned cart recovery for Shopify via Gmail Google Sheets T
Who is this for? This template is ideal for solo store owners, eCommerce marketers, automation beginners, or anyone using Shopify and Gmail who wants to reco...
Add new leads in Lemlist from Airtable
This workflow allows you to add new leads in Lemlist from Airtable. !workflow-screenshot Airtable node: This node lists all the emails that are stored in you...
Add Subscriber and Send Email Campaign
Production-ready n8n automation template for Add Subscriber and Send Email Campaign built by AhiXLight. Seamlessly connects Sendy with 3 configured nodes.
Add new contacts from HubSpot to the email list in Mailchimp
This workflow adds new HubSpot contacts to the Mailchimp email list. Prerequisites - HubSpot account and HubSpot credentials - Mailchimp account and Mailchim...