Productivity · n8n

Auto-Save Gmail Attachments to Google Drive Without Lifting a Finger

Automatically detects new Gmail emails with attachments and saves them directly to a specified Google Drive folder. No more manual downloading and uploading — every attachment lands in Drive the moment it arrives.

difficulty Beginnersetup 20 minresult Every new Gmail attachment is automatically saved to your chosen Google Drive folder in real time.
  1. 1

    Trigger on new Gmail emails

    Add a Gmail Trigger node. Set Event to Message Received. Under Filters, enable Has Attachment so the workflow only fires when an email actually includes a file. Connect your Gmail account via OAuth2 in the Credential field. The node polls every minute by default — you can adjust the interval in Poll Time.

  2. 2

    Filter out emails with no attachments

    Add an IF node connected to the Gmail Trigger. Set Condition to check that {{ $json.attachments }} exists and has a length greater than 0. Route the True branch forward. This acts as a safety net in case the trigger picks up edge-case emails.

  3. 3

    Extract attachment binary data

    Add a Set node on the True branch. Create a field named fileName with the value {{ $json.attachments[0].name }}. This captures the original filename so Google Drive can use it when saving. Keep all other fields as-is.

  4. 4

    Upload the file to Google Drive

    Add a Google Drive node set to Operation: Upload. In File Name, enter {{ $node["Set"].json["fileName"] }}. Set Input Data Field Name to data (the binary field the Gmail Trigger populates). Under Parents, paste the ID of the destination folder from your Drive URL (the string after /folders/). Connect your Google account via OAuth2 in Credential.

Frequently asked questions

How do I find my Google Drive folder ID?

Open the destination folder in Google Drive in your browser. The URL will look like `https://drive.google.com/drive/folders/FOLDER_ID_HERE`. Copy the long string of letters and numbers after `/folders/` and paste it into the Google Drive node's `Parents` field.

Will this save all attachments if an email has more than one?

The basic workflow saves the first attachment. To handle multiple attachments, add a `Split In Batches` node between the Set and Google Drive nodes and loop over `$json.attachments`. For most users, single-attachment handling covers the majority of use cases.

Is my Gmail data safe passing through n8n?

If you run n8n on your own server (self-hosted), data never leaves your infrastructure. If you use n8n Cloud, data is processed on n8n's servers in transit but not stored. Always use OAuth2 credentials rather than passwords for the safest connection.

About this recipe. Recipes on FlowRecipesHub are written for business owners, not developers, and are tested before publishing — how recipes get made. Some ingredient links are affiliate links that cost you nothing — full disclosure.