Skip to content

Cloudflare Worker to securely stream Google Drive files

License

Notifications You must be signed in to change notification settings

ZPlexLabs/zplex-stream

Repository files navigation

zplex-stream 🚀

zplex-stream is a blazing-fast Cloudflare Worker that securely streams files from Google Drive straight to your client apps. With JWT authentication from zplex-api 🔑 and full support for video seeking 🎬, it’s the perfect way to serve content without exposing your credentials.


Features ✨

  • Stream Google Drive files securely to clients 🛡️
  • Authenticate users via JWT issued by zplex-api 🔑 (Users must have 'Stream' capability)
  • Supports HTTP Range requests for smooth video playback ⏯️
  • Lightweight, fast, and production-ready ⚡
  • No sensitive credentials are ever exposed to the client 🔒
  • Workers KV caching of Google access tokens for efficiency

Setup 🛠️

Install dependencies

npm install

Add secrets

For local development and production, add your credentials via Wrangler:

wrangler secret put SECRET_KEY        # Must be the same as zplex-api
wrangler secret put GOOGLE_DRIVE_CLIENT_EMAIL
wrangler secret put GOOGLE_DRIVE_CLIENT_ID
wrangler secret put GOOGLE_DRIVE_PRIVATE_KEY_ID
wrangler secret put GOOGLE_DRIVE_PRIVATE_KEY_PKCS8 # single line, replace newlines with \n

Setup Workers KV

npx wrangler kv namespace create zplex

Run locally

npm run dev

Deploy to Cloudflare

npm run deploy

Usage 📡

GET /stream/:fileId HTTP/1.1
Host: your-worker-domain
Authorization: Bearer <JWT_TOKEN>
Range: bytes=0-1023
  • Authorization: JWT issued by zplex-api 🔑
  • Range: optional; allows partial content requests for video seeking ⏩

About

Cloudflare Worker to securely stream Google Drive files

Resources

License

Stars

Watchers

Forks