A high-performance, scalable implementation of the TUS resumable upload protocol using Cloudflare Workers. This API allows for reliable file uploads with support for resumption, chunking, and progress tracking.
- Full TUS protocol v1.0.0 implementation
- Chunked upload support with dynamic chunk sizing
- Upload resumption and progress tracking
- AWS S3/R2 storage backend
- Redis-based state management
- Rate limiting and file validation
- Health monitoring and metrics
- CORS and security headers
- Authentication middleware
- Node.js 16+ or Bun 1.0+
- AWS S3 or Cloudflare R2 bucket
- Upstash Redis instance
- Cloudflare Workers account
# Using bun (recommended)
bun install
# Using npm
npm install
-
Configure your
wrangler.toml
with appropriate values -
Set up your secrets using wrangler:
wrangler secret put AWS_ACCESS_KEY_ID
wrangler secret put AWS_SECRET_ACCESS_KEY
wrangler secret put UPSTASH_REDIS_REST_URL
wrangler secret put UPSTASH_REDIS_REST_TOKEN
wrangler secret put INTERNAL_API_KEY
- Optional: Configure additional settings in
src/config
# Start development server
bun run dev
# Deploy to Cloudflare Workers
bun run deploy
POST /files
: Initialize uploadPATCH /files/{uploadId}
: Upload file chunkHEAD /files/{uploadId}
: Get upload statusGET /files/{uploadId}/progress
: Get upload progressDELETE /files/{uploadId}
: Cancel uploadGET /health
: Check API health
For detailed API documentation, see API.md
- All endpoints (except /health) require authentication
- File validation for type and size
- Rate limiting per endpoint
- Secure headers and CORS configuration
- Environment-based configuration
- Secrets management through Cloudflare Workers
Contributions are welcome! Please read our Contributing Guidelines for details.
This project is licensed under the MIT License - see the LICENSE file for details.