📁 Automated Google Drive to FTP transfer with JSON logging & reports

⚡ 195 views · 📁 File Management

Description

Google Drive to FTP Transfer Workflow - Setup Guide

Overview

This n8n workflow automatically transfers files from Google Drive to an FTP server on a scheduled basis. It includes comprehensive logging, email notifications, and error handling.

Features

Prerequisites

Before setting up this workflow, ensure you have:

  1. n8n instance running (self-hosted or cloud)
  2. Google Drive account with files to transfer
  3. FTP server with upload permissions
  4. Email service for sending reports (SMTP)

Step-by-Step Setup Instructions

1. Google Drive API Setup

1.1 Create Google Cloud Project

  1. Go to Google Cloud Console
  2. Create a new project or select existing one
  3. Enable the Google Drive API:
    • Navigate to “APIs & Services” → “Library”
    • Search for “Google Drive API”
    • Click “Enable”

1.2 Create OAuth2 Credentials

  1. Go to “APIs & Services” → “Credentials”
  2. Click “Create Credentials” → “OAuth client ID”
  3. Configure consent screen if prompted
  4. Choose “Web application” as application type
  5. Add your n8n instance URL to authorized redirect URIs:
    https://your-n8n-instance.com/rest/oauth2-credential/callback
  6. Note down the Client ID and Client Secret

1.3 Configure n8n Credential

  1. In n8n, go to “Credentials” → “Add Credential”
  2. Select “Google Drive OAuth2 API”
  3. Enter your Client ID and Client Secret
  4. Complete OAuth flow by clicking “Connect my account”
  5. Set credential ID as: your-google-drive-credentials-id

2. FTP Server Setup

2.1 FTP Server Requirements

2.2 Configure n8n FTP Credential

  1. In n8n, go to “Credentials” → “Add Credential”
  2. Select “FTP”
  3. Enter your FTP server details:
    • Host: your-ftp-server.com
    • Port: 21 (or your custom port)
    • Username: your-ftp-username
    • Password: your-ftp-password
  4. Set credential ID as: your-ftp-credentials-id

3. Email Setup (SMTP)

3.1 Choose Email Provider

Configure SMTP settings for one of these providers:

3.2 Configure n8n Email Credential

  1. In n8n, go to “Credentials” → “Add Credential”
  2. Select “SMTP”
  3. Enter your SMTP details:
    • Host: smtp.gmail.com (or your provider)
    • Port: 587
    • Security: STARTTLS
    • Username: your-email@example.com
    • Password: your-app-password
  4. Set credential ID as: your-email-credentials-id

4. Workflow Configuration

4.1 Import Workflow

  1. Copy the workflow JSON from the artifact above
  2. In n8n, click “Import from JSON”
  3. Paste the workflow JSON and import

4.2 Update Credential References

  1. Google Drive nodes: Verify credential ID matches your-google-drive-credentials-id
  2. FTP node: Verify credential ID matches your-ftp-credentials-id
  3. Email node: Verify credential ID matches your-email-credentials-id

4.3 Customize Parameters

FTP Server Settings (Upload to FTP node)
{
  "host": "your-ftp-server.com",           // Replace with your FTP host
  "username": "your-ftp-username",         // Replace with your FTP username
  "password": "your-ftp-password",         // Replace with your FTP password
  "path": "/remote/directory/{{ $json.validFiles[$json.batchIndex].name }}", // Update destination path
  "port": 21                               // Change if using different port
}
Email Settings (Send Report Email node)
{
  "sendTo": "admin@yourcompany.com",       // Replace with your email address
  "subject": "Google Drive to FTP File Transfer - Report"
}
File Filter Settings (Filter & Validate Files node)

In the JavaScript code, update these settings:

const transferNotes = {
  settings: {
    maxFileSizeMB: 50,                     // Change maximum file size
    allowedExtensions: [                   // Add/remove allowed file types
      '.pdf', '.doc', '.docx', '.txt', 
      '.jpg', '.png', '.zip', '.xlsx'
    ],
    autoDeleteAfterTransfer: false,        // Set to true to delete from Drive after transfer
    verifyTransfer: true                   // Keep true for verification
  }
};
Google Drive Notes Storage (Upload Notes to Drive node)
{
  "parents": {
    "parentId": "your-notes-folder-id"     // Replace with actual folder ID from Google Drive
  }
}

5. Schedule Configuration

5.1 Modify Schedule Trigger

In the “Schedule Trigger” node, adjust the interval:

{
  "rule": {
    "interval": [
      {
        "field": "hours",
        "hoursInterval": 6               // Change to desired interval (hours)
      }
    ]
  }
}

Alternative schedule options:

5.2 Webhook Configuration

The webhook trigger is available at:

POST https://your-n8n-instance.com/webhook/webhook-transfer-status

Use this for manual triggers or external integrations.

6. Testing and Validation

6.1 Test Connections

  1. Test Google Drive: Run “Get Drive Files” node manually
  2. Test FTP: Upload a test file using “Upload to FTP” node
  3. Test Email: Send a test email using “Send Report Email” node

6.2 Run Test Transfer

  1. Activate the workflow
  2. Click “Execute Workflow” to run manually
  3. Monitor execution in the workflow editor
  4. Check for any error messages or failed nodes

6.3 Verify Results

7. Monitoring and Maintenance

7.1 Workflow Monitoring

7.2 Regular Maintenance

8. Troubleshooting

8.1 Common Issues

Google Drive Authentication Errors:

FTP Connection Failures:

Email Delivery Issues:

File Transfer Failures:

8.2 Debug Mode

Enable debug mode by:

  1. Adding console.log statements in code nodes
  2. Using “Execute Workflow” with step-by-step execution
  3. Checking node outputs for data validation

9. Advanced Customizations

9.1 Additional File Filters

Add custom filtering logic in the “Filter & Validate Files” node:

// Example: Filter by modification date
const isRecentFile = new Date(file.modifiedTime) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000); // Last 7 days

// Example: Filter by folder location
const isInSpecificFolder = file.parents && file.parents.includes('specific-folder-id');

9.2 Enhanced Reporting

Customize the email report template in “Send Report Email” node:

<h2>📊 File Transfer Report</h2>
<div>
  <h3>Summary</h3>
  <ul>
    <li><strong>Date:</strong> {{ new Date().toLocaleString('en-US') }}</li>
    <li><strong>Success Rate:</strong> {{ Math.round((successfulTransfers / totalFiles) * 100) }}%</li>
    
  </ul>
</div>

9.3 Integration with Other Services

Add nodes to integrate with:

10. Security Considerations

10.1 Credential Security

10.2 Network Security

10.3 Data Privacy

Support and Resources

Getting Help

If you encounter issues:

  1. Check the troubleshooting section above
  2. Review n8n execution logs for error details
  3. Search the n8n community forum for similar issues
  4. Create a support ticket with detailed error information

Note: Replace all placeholder values (URLs, credentials, IDs) with your actual configuration before running the workflow.

🔗 Nodes Used

Send Email, Write Binary File, Webhook, Google Drive, FTP, Schedule Trigger

đŸ“„ Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup