Skip to main content

Cross-platform Google Drive file uploader and downloader CLI

Project description

EH Google Drive Uploader

PyPI version Python 3.8+ License: MIT

Cross-platform Python CLI tool to upload and download files to/from Google Drive.

By Esmail Ebrahim Hamza (@EsmailEbrahim)

Features

  • Upload any file type (including large ZIP archives)
  • OAuth2 secure authentication (browser login once, reuse token)
  • Upload to specific Drive folders
  • Download files by ID
  • Search files by name
  • Rename files on upload
  • Cross-platform: Windows, Linux, macOS
  • Resumable uploads for reliability

Installation

From PyPI (Recommended)

pip install eh-gdrive-uploader
eh-gdrive-uploader --version

From Source

git clone https://github.com/EsmailEbrahim/eh-gdrive-uploader.git
cd eh-gdrive-uploader
pip install -e .

Usage

# Upload file
eh-gdrive-uploader myfile.zip

# Upload to folder
eh-gdrive-uploader myfile.zip -f FOLDER_ID

# Rename
eh-gdrive-uploader myfile.zip -n newname.zip

# Download
eh-gdrive-uploader -d FILE_ID
eh-gdrive-uploader -d FILE_ID -o ./downloads/

# List files
eh-gdrive-uploader --list            # or -l

# Search files
eh-gdrive-uploader --search "doc"    # or -s

# Version info
eh-gdrive-uploader --version         # or -v

# Setup help
eh-gdrive-uploader --setup

Quick Start

1. Clone & Setup Environment

From Source (Development)

# Clone repo
git clone https://github.com/EsmailEbrahim/eh-gdrive-uploader.git
cd eh-gdrive-uploader

# Create virtual environment
python -m venv venv

# Activate (Windows)
venv\Scripts\activate
# Activate (Linux/macOS)
# source venv/bin/activate

# Install in editable mode
pip install -e .

# Verify installation
eh-gdrive-uploader --version

2. Google Cloud Setup (One-time)

  1. Go to Google Cloud Console
  2. Create new project (top-left dropdown)
  3. Enable Google Drive API:
    • Navigation menu → APIs & Services → Library
    • Search "Google Drive API" → Click Enable
  4. Create OAuth Credentials:
    • APIs & Services → Credentials
    • Click Create Credentials → OAuth client ID
    • Application type: Desktop application
    • Name: Drive Uploader
    • Click CreateDownload JSON
  5. Place credentials:
    • Copy downloaded file to: ~/.gdrive_uploader/credentials.json
    • Windows: C:\Users\YOURNAME\.gdrive_uploader\credentials.json
    • Ubuntu: /home/YOURNAME/.gdrive_uploader/credentials.json

Or run: python -m eh_gdrive_uploader.gdrive_upload --setup for detailed instructions.

3. First Run (Authentication)

python -m eh_gdrive_uploader.gdrive_upload myfile.zip

Browser will open for Google login → Authorization token saved automatically.


Error: "Access blocked: Test has not completed the Google verification process"

Solution:

  1. Go to Google Cloud Console
  2. Select your project → APIs & ServicesOAuth consent screen
  3. Under Test users, click Add users
  4. Add your Gmail address (YOUREMAIL@gmail.com)
  5. Save and retry the script

Usage

Basic Upload

# Upload to Drive root
python -m eh_gdrive_uploader.gdrive_upload backup.zip

# Upload with progress
python -m eh_gdrive_uploader.gdrive_upload "C:\Users\Me\Documents\archive.zip"

Upload to Specific Folder

# Get folder ID from Drive URL (last part after /folders/)
python -m eh_gdrive_uploader.gdrive_upload backup.zip -f 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms

Download from Google Drive

# Download file by ID (saves to current directory with original name)
eh-gdrive-uploader -d FILE_ID

# Download to specific directory (creates if doesn't exist)
eh-gdrive-uploader -d FILE_ID -o ./downloads/

# Download with new name
eh-gdrive-uploader -d FILE_ID -o myfile.zip

# Get file ID from list or URL (https://drive.google.com/file/d/FILE_ID/view)

Note: Google Docs, Sheets, and Slides are automatically exported to Microsoft Office formats (.docx, .xlsx, .pptx).

Search Files

# Search files by name
eh-gdrive-uploader --search "report"

# Search with partial match
eh-gdrive-uploader -s "backup"

Rename on Upload

python -m eh_gdrive_uploader.gdrive_upload backup.zip -n "backup-2026-02-05.zip"

List Recent Files

python -m eh_gdrive_uploader.gdrive_upload --list

Show Setup Help

python -m eh_gdrive_uploader.gdrive_upload --setup

Environment Management

Activate environment (Windows):

venv\Scripts\activate

Activate environment (Ubuntu/Linux):

source venv/bin/activate

Deactivate (any platform):

deactivate

Project Structure

eh-gdrive-uploader/
├── eh_gdrive_uploader/   # Main package
│   ├── __init__.py       # Package initializer
│   └── gdrive_upload.py  # Main script (CLI entry point)
├── venv/                 # Virtual environment (not in git)
├── .gitignore            # Ignore credentials & cache
├── CHANGELOG.md          # Project changelog
├── LICENSE               # Licens file (MIT)
├── Makefile              # Make commands for setup
├── pyproject.toml        # Python project metadata
├── README.md             # This file
├── requirements.txt      # Python dependencies
└── requirements-dev.txt  # Development dependencies

Version History

See CHANGELOG.md for details.

Security Notes

  • Never commit credentials.json or token.pickle — they are in .gitignore
  • Tokens stored locally in ~/.gdrive_uploader/ (user home directory)
  • First run requires browser authentication; subsequent runs use saved token

Troubleshooting

Issue Solution
credentials.json not found Run setup step 2, check file is in ~/.gdrive_uploader/
Browser doesn't open Check default browser; use same machine with GUI
ModuleNotFoundError Run pip install -r requirements.txt inside venv
Token expired Delete ~/.gdrive_uploader/token.pickle and re-run

Author

Esmail Ebrahim Hamza

License

MIT License - Free for personal and commercial use. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eh_gdrive_uploader-1.1.1.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eh_gdrive_uploader-1.1.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file eh_gdrive_uploader-1.1.1.tar.gz.

File metadata

  • Download URL: eh_gdrive_uploader-1.1.1.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for eh_gdrive_uploader-1.1.1.tar.gz
Algorithm Hash digest
SHA256 29e0b5107cd48caafeaa50bd2e79c3d2279a4ca7b92239bd0aaaf3b1d8993752
MD5 190c3d8ab0c4bfe50050cf1f69533289
BLAKE2b-256 a91670e159157816b87e63c17e5982cb2c5a06ec990439dea2ced019b6f30707

See more details on using hashes here.

File details

Details for the file eh_gdrive_uploader-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for eh_gdrive_uploader-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 24df006591e9e560c3e5b7522926c4d2cb67025ceddf7e4426aa83eafa51c061
MD5 db6ad4fbf3141b53c779d1079fc3126b
BLAKE2b-256 72b14f73d6e31adec52528c85416160caf521d2316c6bc3a4bbfd330632564a0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page