Automate Gmail Attachments to Google Drive with n8n (So You Never Manually Download Again)
Picture this…
You sit down with a fresh coffee, open your inbox, and there they are: a pile of emails with attachments that all need to be saved to Google Drive. One by one. Download, upload, repeat. By attachment number three, you are questioning your life choices.
Good news: n8n can do that boring part for you. Automatically. Quietly. Relentlessly. While you do literally anything else.
What this n8n template actually does
This workflow template is a small but mighty three-node setup that:
- Grabs emails from Gmail (optionally filtered by label)
- Pulls out their attachments and uploads them to a specific Google Drive folder
- Captures a shareable Drive link for each uploaded file so you can use it in the rest of your automations
It uses only three nodes:
- Gmail node – gets messages with attachments
- Google Drive node – uploads the attachment as a file
- Set node – stores the Drive
webViewLinkso you can pass it onward
Perfect for archiving incoming attachments, saving video files, or building a searchable repository without ever touching the “Download” button again.
Why automate Gmail to Google Drive in the first place?
If you enjoy repetitive mouse clicks, feel free to skip this part. For everyone else, here is what this workflow gives you:
- Time back – no more opening emails, saving files, and re-uploading them to Drive like it is 2009.
- Centralized storage – all your attachments land in one Google Drive folder that is easy to share and search.
- Automation fuel – once the file is in Drive, you can trigger more workflows like notifications, logging to a spreadsheet, or kicking off a review process.
What you need before you start
Before you let n8n take over the attachment drudgery, make sure you have:
- An n8n instance (cloud or self-hosted)
- Gmail OAuth2 credentials connected to n8n
- Google Drive OAuth2 credentials connected to n8n
- A Google Drive folder ID where attachments should be saved
Quick tour of the workflow
At a high level, the workflow does this:
- Gmail node fetches messages using
getAlland a specific label filter. - Google Drive node uploads the attachment from the Gmail binary data into your chosen folder.
- Set node grabs the
webViewLinkfrom the Drive response and stores it in a field you can use later.
That is it. Three nodes, zero manual downloads, and your future self sends you a silent thank you.
Step-by-step: setting up the n8n workflow
1) Configure the Gmail node to fetch attachments
This is where n8n goes into your Gmail and pulls the messages you care about.
In the Gmail node, use these settings:
- Resource:
message - Operation:
getAll - Additional fields:
- Format:
resolved– this tells Gmail to decode attachments so they show up as binary data. - Label IDs: add the label or labels that should be used as filters, for example a label you apply to emails with attachments you want to archive.
- Format:
How attachments appear in n8n
- With
format: resolved, Gmail returns attachments as binary properties likeattachment_0,attachment_1, and so on. - n8n exposes those in the item’s binary field, which is exactly what the Google Drive node will use for the upload.
Tip for only processing new emails
- Create a dedicated Gmail label (for example,
to-drive), use it as the filter in the Gmail node, and then have another step later that marks or moves messages after processing. - This way, the workflow does not keep reprocessing the same emails over and over.
2) Configure the Google Drive node to upload the file
Next up, you tell n8n where to park those attachments in Drive.
Set up the Google Drive node like this:
- Operation:
uploadorupload file - Name: use an expression so the filename is created dynamically, for example:
{{$binary.attachment_0.fileName}} - Parents: the Google Drive folder ID where files should be stored, for example:
1I-tBNWFhH2Fwcs...-nXBr - Binary Data:
true - Binary Property Name:
attachment_0(or whichever attachment index you want to upload) - Authentication: your configured Google Drive OAuth2 credential
- Resolve Data:
trueso the node returns file metadata includingwebViewLink
Notes and pro tips
- If emails can have multiple attachments, you can:
- Split the attachments into separate items and loop over them with a SplitInBatches or Function node.
- Configure your workflow so the Drive node runs once per attachment, depending on how you structure your items.
- Make your filename expression a bit smarter to avoid collisions. For example, include the email date or message ID in the name along with the original filename.
3) Use a Set node to capture the Drive link
Once the file is safely parked in Google Drive, the Drive node returns metadata about that file. This includes the magic field you care about: webViewLink.
In the Set node:
- Create a new string field, for example mp4_attachment.
- Set its value to an expression that points to the Drive link, such as:
{{$json["webViewLink"]}}
or the correct JSON path for your specific Drive node output. - Check the output preview to confirm that
webViewLinkis present and correctly mapped.
Important note about sharing
The webViewLink will let people with existing permission view the file in their browser. It does not automatically make the file public. If you want “anyone with the link” access, you need to adjust permissions after the upload step.
Making the Google Drive file shareable (optional)
If you want to send links to people who are not already in your Drive or do not have access, you will need to tweak permissions a bit.
You have two main options:
- Use the Google Drive node’s permissions or sharing operation (if available in your n8n version) to add a permission like:
{ type: 'anyone', role: 'reader' } - Use an HTTP Request node to call the Google Drive REST API directly and add permissions if your Drive node does not expose that feature.
In both cases, your Google Drive OAuth credential must have permission to change file permissions.
Handling multiple attachments and larger batches
Real-life emails love to come with multiple attachments at once. Here are some common patterns for handling that gracefully:
- Split attachments into separate items so that each file is handled individually. Upload each one in a loop and collect all the returned links into an array for later use.
- Use a Function node to dynamically rename and map each binary property so the Google Drive node receives attachments one at a time.
- Use SplitInBatches when processing a lot of messages to avoid hitting API rate limits and to keep your workflow stable.
Common issues and how to fix them
When something does not work, it is usually one of these usual suspects:
- Permission errors
Double check that:- Your Gmail OAuth credentials are correctly authorized and include scopes for reading messages and attachments.
- Your Google Drive OAuth credentials have scopes for uploading files and managing permissions (if you are changing sharing settings).
- Missing binary attachments
Make sure:- The Gmail node Format is set to
resolved. - You preview the Gmail node output and confirm binary keys like
attachment_0orattachment_1exist.
- The Gmail node Format is set to
- Drive link exists but the file is private
That means the file is uploaded correctly, but permissions are still restricted. Add a permission step in the workflow or adjust the sharing settings of the destination folder in Drive. - Very large attachments
Check Google Drive upload limits and any network timeout constraints. If your n8n setup or Drive integration supports chunked uploads, consider using that for big files.
Security considerations
Automation is great, but security still matters:
- Be careful about which attachments you automatically store. Sensitive files may need encryption or a restricted Drive folder.
- Rotate OAuth credentials regularly and keep their scopes limited to what the workflow actually needs.
- Audit who has access to the destination Drive folder and to any links you generate and share.
Simple troubleshooting checklist
If the workflow misbehaves, walk through this quick checklist:
- Open the Gmail node output and confirm that:
- The message body is there.
- Binary attachments like
attachment_0appear in the binary tab.
- Open the Google Drive node output and check the API response for:
idwebViewLink
- If you need public links and the Drive node does not support permissions, test making the file public via an HTTP Request node using the Drive API.
- If an attachment is missing, revisit your Gmail label or search filter and inspect the email’s MIME parts to confirm the attachment is actually there.
What you can build on top of this workflow
Once you have the Drive link, this workflow becomes a launching pad for all kinds of automation:
- Post the file link directly to Slack or Microsoft Teams channels.
- Write the file metadata and link to a Google Sheet or Airtable base for tracking and reporting.
- Send an automated email or webhook containing the saved file link.
- Trigger downstream processes like video transcoding, content ingestion, or internal review workflows.
From manual downloads to fully automated bliss
This three-node n8n workflow is a simple but powerful building block:
- Fetch attachments from Gmail
- Store them in Google Drive
- Capture shareable links for further automation
Once it is in place, you can stop babysitting your inbox and let n8n quietly move files where they belong.
Next steps: try the template in your n8n instance
Ready to deploy?
Here is how to get this running quickly:
- Import the JSON template into your n8n instance.
- Connect your Gmail and Google Drive OAuth2 credentials.
- Set the target Google Drive folder ID.
- Test with an example email that has the label used in your Gmail node filter.
If you want to level it up with multiple attachment handling, Slack notifications, or automatic permission management, feel free to reach out. A few extra nodes can turn this into a fully featured attachment handling system.
Call to action: Try this workflow in your n8n instance and retire the manual download-upload routine. If you need a custom version tailored to your exact use case, contact us for a free consultation and we will help you automate your email attachment process from end to end.
