Automated Attachment Handler from Gmail to Google Drive with File Size Filtering - n8n Workflow

Use this powerful n8n workflow to automatically download and filter multiple Gmail attachments by size, uploading approved files directly to Google Drive. A necessary n8n template for efficiency.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Operations Managers: Seeking reliable automation to archive important documents sent via email without manual intervention.
Technical Users and Developers: Needing an advanced n8n workflow example demonstrating how to correctly split and reference multiple binary files (attachments).
Teams using n8n: Those who require conditional file storage based on metrics like file size.
Efficiency Seekers: Anyone looking for a robust, no-code n8n template to streamline their Gmail and Google Drive interactions.

Overview

Handling email attachments, especially when multiple files are involved, is often a tedious and error-prone process. This specialized n8n workflow solves this by providing a hands-off approach to email file management. It utilizes the power of the n8n node ecosystem to monitor a specified Gmail account for emails matching strict criteria (unread, from a specific sender). Crucially, this n8n workflow demonstrates how to use the Split Out n8n node to correctly process multiple attachments as individual items, allowing for per-file processing and conditional routing.

After splitting the binaries, the workflow intelligently uses a Switch n8n node to evaluate the file size. This allows users to implement business logic—for instance, ignoring small junk files or routing overly large files to a separate notification channel—before uploading only the relevant files to Google Drive. This n8n template is a prime example of advanced logic implemented without custom code.

How it Works

This automation starts with the specialized Gmail Trigger n8n trigger node, which is configured to look for unread emails from a specific sender and, critically, is set to automatically download all attachments associated with the email.


  1. Trigger and Download: The Gmail Trigger fires when a matching email arrives, downloading the attachments as binary data, prefixed with attachment_.

  2. Split Binaries: The Split Out n8n node receives the email item containing multiple binary files. It then splits the binary data into separate items, ensuring that each subsequent n8n node processes one attachment at a time. This is a vital step for ensuring individual file handling.

  3. Conditional Filtering: The Switch n8n node evaluates the size of the current attachment item using expressions ($binary.values()[0].fileSize). This n8n node routes the files into three paths:

Large Files ( > 300): Routed to a placeholder node for notification.
Medium Files ( > 10): Routed to the successful upload path.
* Other/Fallback: Routed to a placeholder node for ignoring small files.

  1. Upload to Drive: The main path connects to the Google Drive n8n node, which uploads the binary file. Thanks to the use of dynamic expressions in the Google Drive n8n node, the file name and the binary input field name are correctly referenced, ensuring the correct file is saved to the designated Google Drive folder.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and import it directly into your n8n instance via the 'Workflows' screen using the 'New' button and selecting 'Import from JSON'.

  2. Gmail Trigger Setup: Click on the Gmail Trigger n8n node. You must set up a Gmail OAuth2 credential. Additionally, modify the 'Sender' filter to match the specific email address you wish to monitor.

  3. Google Drive Setup: Open the Google Drive n8n node. Create or select an existing Google Drive OAuth2 credential. Ensure the 'Folder ID' is updated to the specific destination folder where you want the filtered attachments stored.

  4. Activation: Once credentials and necessary parameters are updated, ensure the n8n workflow is set to 'Active' to start monitoring incoming emails.

Node Details

Gmail Trigger: The initial n8n trigger for the workflow. It uses filters for specific senders and download unread emails, ensuring the attachments are immediately available as binary data for the next n8n node.
Split Out: Crucial n8n node configured to split the $binary field. This transforms one email item with many attachments into many items, each containing a single attachment, enabling per-file filtering.
Switch: This n8n node acts as the conditional router. It uses complex expressions referencing the binary data's file size property to determine if the attachment should be uploaded, ignored, or flagged, providing advanced flow control within the n8n workflow.
Google Drive: The final action n8n node. It dynamically references the file name and binary data using expressions (={{ $binary.values()[0].fileName }} and ={{ $binary.keys()[0] }}), ensuring the correct attachment is uploaded to the target folder.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by
Hubschrauber
Hubschrauber

Software developer specializing in "back-end plumbing" to connect and sync data between large corporate systems, enabling application distribution/migration, scaling, and containerization. Using n8n for various orchestration tasks both at home and "on the job."

Featured*