# ComfyUI DriveSend Node A ComfyUI custom node for seamless Google Drive uploads with **optional** encryption capabilities. Automatically upload your ComfyUI output files (images and videos) to Google Drive cloud storage. ## โš ๏ธ Authentication Methods - READ FIRST | Method | Lifespan | Best For | Effort | |--------|----------|----------|--------| | **Service Account** | โœ… **Permanent** (never expires) | Cloud/RunPod | Medium setup | | **OAuth 2.0** | โŒ **7 days** (must re-auth weekly) | Not recommended | Easy setup | **We strongly recommend Service Account** for any persistent use. OAuth tokens expire every 7 days in Google's "testing mode" and there is no workaround without paying for Google Workspace or going through Google's app verification process. --- ## ๐Ÿ”„ How It Works ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ CLOUD (RunPod, etc.) โ”‚ โ”‚ โ”‚ โ”‚ ComfyUI generates files โ”€โ”€โ†’ DriveSend Node โ”€โ”€โ†’ Uploads to Google Drive โ”‚ โ”‚ (png, mp4, etc.) โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Encryption OPTIONAL โ”‚ โ”‚ โ”‚ โ”‚ โ˜ OFF: file.png โ”‚ โ”‚ โ”‚ โ”‚ โ˜‘ ON: file.png.enc โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ–ผ ๐Ÿ“ GOOGLE DRIVE โ”‚ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ YOUR LOCAL MACHINE โ”‚ โ”‚ โ”‚ โ”‚ Google Drive syncs/downloads โ”€โ”€โ†’ If encrypted: Run decrypt script (local) โ”‚ โ”‚ โ”€โ”€โ†’ file.png (viewable!) โ”‚ โ”‚ โ”‚ โ”‚ If not encrypted: Ready to use! โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` --- ## ๐Ÿ’พ Installation ```bash cd ComfyUI/custom_nodes/ git clone https://github.com/machinepainting/ComfyUI_DriveSendNode.git cd ComfyUI_DriveSendNode pip install -r requirements.txt ``` --- ## ๐Ÿ”ง Google Cloud Setup (Service Account - Recommended) ### Step 1: Create Google Cloud Project 1. Go to [Google Cloud Console](https://console.cloud.google.com/) 2. Sign in with a **personal Gmail account** (not work/school - they often have restrictions) 3. Click **Select a project** โ†’ **New Project** 4. Name it (e.g., `ComfyUI-DriveSend`) โ†’ **Create** ### Step 2: Enable Google Drive API 1. Go to **APIs & Services** โ†’ **Library** 2. Search for **Google Drive API** 3. Click **Enable** ### Step 3: Create Service Account 1. Go to **IAM & Admin** โ†’ **Service Accounts** 2. Click **+ Create Service Account** 3. Name it (e.g., `comfyui-uploader`) 4. Click **Create and Continue** 5. Skip optional steps โ†’ **Done** ### Step 4: Fix Organization Policy (IMPORTANT - New Google Accounts) Google now blocks service account key creation by default. You MUST disable this policy first. #### 4a. Grant Yourself Policy Admin Role 1. Go to **IAM & Admin** โ†’ **IAM** 2. Click the dropdown at top-left and select your **organization** (your email domain), not the project 3. Click **+ Grant Access** 4. Principal: **your email** 5. Role: search for **Organization Policy Administrator** 6. Click **Save** #### 4b. Enable the Organization Policy API Open **Cloud Shell** (terminal icon at top-right) and run: ```bash gcloud services enable orgpolicy.googleapis.com --project=YOUR_PROJECT_ID ``` Replace `YOUR_PROJECT_ID` with your actual project ID. #### 4c. Disable the Key Creation Restrictions Run these commands in Cloud Shell: ```bash gcloud org-policies reset iam.disableServiceAccountKeyCreation --project=YOUR_PROJECT_ID gcloud org-policies reset iam.managed.disableServiceAccountKeyCreation --project=YOUR_PROJECT_ID ``` ### Step 5: Create and Download the Key 1. Switch back to your **project** (click dropdown top-left, select your project) 2. Go to **IAM & Admin** โ†’ **Service Accounts** 3. Click on your service account 4. Go to **Keys** tab 5. Click **Add Key** โ†’ **Create new key** โ†’ **JSON** โ†’ **Create** 6. **IMPORTANT:** Rename the downloaded file to exactly: `service_account.json` ### Step 6: Share Your Google Drive Folder 1. Go to [Google Drive](https://drive.google.com) 2. Create a new folder (e.g., `ComfyUI_Uploads`) 3. Right-click the folder โ†’ **Share** 4. Open your `service_account.json` file and find the `client_email` value (looks like `name@project-id.iam.gserviceaccount.com`) 5. Paste that email in the Share dialog 6. Set permission to **Editor** 7. Click **Share** (uncheck "Notify people" if prompted) ### Step 7: Get Your Folder ID 1. Open the folder in Google Drive 2. Look at the URL: `https://drive.google.com/drive/folders/XXXXXXXXXXXXXXXXX` 3. Copy the long string after `/folders/` โ€” that's your **Folder ID** --- ## ๐Ÿš€ Local Setup (Quick Test) 1. Place `service_account.json` in the `ComfyUI_DriveSendNode` folder 2. Add the **DriveSend Setup** node to ComfyUI 3. Configure: - `auth_method`: **service_account** - `folder_id`: your folder ID - `owner_email`: **your Gmail address** (required!) - `storage_method`: **env_file** - `encryption_key_method`: **off** (for testing) 4. Run the node 5. Add **DriveSend AutoUploader** node and run a workflow --- ## โ˜๏ธ RunPod / Cloud Setup (Persistent) ### Option A: Custom Template (Recommended - One-Time Setup) 1. Run the **DriveSend Setup** node locally with `storage_method`: **display_only** 2. Copy the output values from the console 3. In RunPod, go to **Secrets** and create: | Secret Name | Value | |-------------|-------| | `GOOGLE_DRIVE_FOLDER_ID` | Your folder ID | | `GOOGLE_SERVICE_ACCOUNT_JSON` | The base64 string from setup | | `GOOGLE_OWNER_EMAIL` | Your Gmail address | | `comfyui_encryption_key` | (only if using encryption) | 4. Create or edit a **Pod Template**: - Click **Edit Template** โ†’ **Environment Variables** - Add each variable, linking to secrets: - Key: `GOOGLE_DRIVE_FOLDER_ID` โ†’ Value: `{{ RUNPOD_SECRET_GOOGLE_DRIVE_FOLDER_ID }}` - Key: `GOOGLE_SERVICE_ACCOUNT_JSON` โ†’ Value: `{{ RUNPOD_SECRET_GOOGLE_SERVICE_ACCOUNT_JSON }}` - Key: `GOOGLE_OWNER_EMAIL` โ†’ Value: `{{ RUNPOD_SECRET_GOOGLE_OWNER_EMAIL }}` - Key: `comfyui_encryption_key` โ†’ Value: `{{ RUNPOD_SECRET_comfyui_encryption_key }}` - Click **Set Overrides** 5. Deploy pods using this template โ€” credentials persist automatically! ### Option B: Manual Environment Variables (Each Pod) If you don't want to create a template, manually add the environment variables each time you create a pod. This is more tedious but works the same way. --- ## ๐Ÿ“‹ Node Settings Reference ### DriveSend Setup Node | Field | Description | |-------|-------------| | `auth_method` | `service_account` (recommended) or `oauth` | | `folder_id` | Google Drive folder ID from URL | | `owner_email` | **Your Gmail** - required for service account! | | `storage_method` | `display_only` (cloud) or `env_file` (local) | | `encryption_key_method` | `off`, `Display Only`, or `save to .env` | | `service_account_path` | Default: `service_account.json` | ### DriveSend AutoUploader Node | Field | Description | |-------|-------------| | `watch_directory` | Folder to monitor (default: ComfyUI output) | | `auth_method` | Must match setup node | | `folder_id` | Override folder ID (or leave blank to use env var) | | `owner_email` | Override owner email (or leave blank to use env var) | | `enable_encryption` | Encrypt files before upload | | `Post_Delete_Enc` | Delete .enc files after upload | | `Subfolder_Monitor` | Watch subfolders too | | `run_process` | Start/stop the monitor | --- ## โ“ Why is `owner_email` Required? **Service accounts have 0 GB storage quota.** When a service account uploads a file, it owns that file โ€” but it has no storage space! The `owner_email` setting transfers ownership to your personal Gmail account after upload, so the file uses YOUR storage quota (15 GB free). Without this, uploads will fail with: `403 storageQuotaExceeded` --- ## ๐Ÿ” Encryption (Optional) Enable encryption to protect files in cloud storage: 1. In Setup node: set `encryption_key_method` to **Display Only** or **save to .env** 2. In AutoUploader: set `enable_encryption` to **True** 3. Save your encryption key securely โ€” you need it to decrypt files! See the `/scripts/` folder for decryption scripts (run on your local machine after downloading). --- ## ๐Ÿ› ๏ธ Troubleshooting ### "service_account.json NOT FOUND" - Rename your downloaded key file to exactly `service_account.json` - Place it in the `ComfyUI_DriveSendNode` folder ### "403 storageQuotaExceeded" - Set `owner_email` to your Gmail address - Make sure the folder is shared with your service account email ### "Organization Policy blocks key creation" - Follow Step 4 in the setup guide to disable the policy restrictions - Run the gcloud commands in Cloud Shell ### "Permission denied" on upload - Make sure you shared the Google Drive folder with the service account email - The service account needs **Editor** access --- ## ๐Ÿ“ Repository Structure ``` ComfyUI_DriveSendNode/ โ”œโ”€โ”€ __init__.py โ”œโ”€โ”€ drivesend_uploader_node.py โ”œโ”€โ”€ drivesend_setup_node.py โ”œโ”€โ”€ gdrive_upload.py โ”œโ”€โ”€ gdrive_auth_manager.py โ”œโ”€โ”€ encrypt_file.py โ”œโ”€โ”€ monitor_output.py โ”œโ”€โ”€ requirements.txt โ”œโ”€โ”€ README.md โ”œโ”€โ”€ .gitignore โ””โ”€โ”€ scripts/ โ”œโ”€โ”€ decrypt_folder.py โ”œโ”€โ”€ decrypt_folder_mac.sh โ”œโ”€โ”€ encrypt_folder_mac.sh โ”œโ”€โ”€ decrypt_folder_win.py โ”œโ”€โ”€ encrypt_folder_win.py โ”œโ”€โ”€ decrypt_folder_linux.sh โ””โ”€โ”€ encrypt_folder_linux.sh ``` --- ## ๐Ÿงช Status **Testing in Progress** โ€” Based on the working [DropSend Node](https://github.com/machinepainting/ComfyUI_DropSendNode). Please report issues on GitHub! --- ## License MIT