Skip to main content

Upload & rename videos to Google Drive via Apps Script from URL

Workflow preview

Workflow preview
100%
Upload & rename videos to Google Drive via Apps Script from URL preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Google Script Workflow: Upload File from URL to Google Drive (via n8n) Purpose: This lightweight Google Apps Script acts as a server endpoint that receives a file URL (from ), downloads the f...

Best for

  • File Management automation workflows
  • beginner n8n builders looking for reusable templates

Tools used

n8n-nodes-base.manualtrigger, n8n-nodes-base.googledrive, n8n-nodes-base.httprequest

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Joseph.

Original n8n.io source

1.1 Workflow description

Title
Upload & rename videos to Google Drive via Apps Script from URL
Workflow name
Upload & rename videos to Google Drive via Apps Script from URL

📄 Google Script Workflow: Upload File from URL to Google Drive (via n8n)

🔧 Purpose:

This lightweight Google Apps Script acts as a server endpoint that receives a file URL (from n8n), downloads the file, uploads it to your specified Google Drive folder, and responds with the file’s metadata (like Drive file ID and URL). This is useful for large video/audio files that n8n cannot handle directly via HTTP Download nodes.


🚀 Setup Steps:

1. Create a New Script Project


2. Paste the Script Code

Replace the default Code.gs content with the following (your custom script):

function doPost(e) {
  const SECRET_KEY = 'your-strong-secret-here'; // Set your secret key here

  try {
    const data = JSON.parse(e.postData.contents);

    // 🔒 Check for correct secret key
    if (!data.secret || data.secret !== SECRET_KEY) {
      return ContentService.createTextOutput("Unauthorized")
        .setMimeType(ContentService.MimeType.TEXT);
    }

    const videoUrl = data.videoUrl;
    const folderId = 'YOUR_FOLDER_ID_HERE'; // Replace with your target folder ID
    const folder = DriveApp.getFolderById(folderId);

    const response = UrlFetchApp.fetch(videoUrl);
    const blob = response.getBlob();
    const file = folder.createFile(blob);
    file.setName('uploaded_video.mp4'); // You can customize the name

    return ContentService.createTextOutput(file.getUrl())
      .setMimeType(ContentService.MimeType.TEXT);
  } catch (err) {
    return ContentService.createTextOutput("Error: " + err.message)
      .setMimeType(ContentService.MimeType.TEXT);
  }
}

3. Generate & Set Up Secret Key

To allow authorized post requests to your script only, we need to generate a secret key from aany reliable key generator.

  • You can head over to acte, click generate and copy the "Encryption key 256".
  • Paste it in the 'your-strong-secret-here' placeholder in your script then click save
  const SECRET_KEY = 'your-strong-secret-here'; // Set your secret key here;

4. Replace Folder ID in Code

  • Open the target Drive folder in your browser
  • The folder ID is the part of the URL after /folders/
    Example:
    https://drive.google.com/drive/u/0/folders/1Xabc12345678defGHIJklmn
    
  • Paste that ID in the script:
    var folderId = "1Xabc12345678defGHIJklmn";
    

5. Set Up Deployment as Web App

  • Click “Deploy” > “Manage Deployments” > “New Deployment”
  • Under Select type, choose Web app
  • Description: Upload from URL to Drive
  • Execute as: Me
  • Who has access: Anyone
  • Click Deploy
  • Authorize the script when prompted
  • Copy the Web App URL

📤 How to Use in n8n

1. HTTP Request Node

  • Method: POST
  • URL: (your web app URL)
  • Secret Key: (Secret Key set in script)
  • Body Content Type: JSON
  • Paste code:
{
  "videoUrl": "https://example.com/path/to/your.mp4",
  "secret": "your-strong-secret-here"
}
  • videoUrl: The file download URL
  • secret: The generated and set up secret key

2. Rename Node

  • A simple drive update node to rename the file using the file drive url returned from the script.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When clicking ‘Test workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 2 - Rename Uploaded Video

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 3 - Send URL to GDrive Script and Upload

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

3. Summary Table

Workflow Upload & rename videos to Google Drive via Apps Script from URL
Complexity beginner
Nodes 3
Categories File Management
Author Joseph
Published 01 May 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3815/3815.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Upload & rename videos to Google Drive via Apps Script from URL do?

Google Script Workflow: Upload File from URL to Google Drive (via n8n) Purpose: This lightweight Google Apps Script acts as a server endpoint that receives a file URL (from ), downloads the f...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your File Management use case.