1. Architecture & Storage
MyDrive is an enterprise-grade, self-hosted file management and media streaming server built with FastAPI and SQLite WAL mode.
It strictly separates user spaces on disk:
2. Linux VPS / Bare Metal Setup
Deploy directly on any Ubuntu, Debian, Fedora, Arch, or Rocky Linux server:
3. Docker & Docker Compose
The included docker-compose.yml sets up persistent storage volumes with non-root container security:
4. Android Pocket Server (Termux)
Transform an old or spare Android smartphone into a zero-power 24/7 personal cloud server:
5. Chunked Upload Protocol
Traditional multipart HTTP uploads load entire files into system memory, crashing servers on 5GB+ files. MyDrive uses an intelligent chunked upload pipeline:
- The frontend splits files into 4MB binary slices.
- Each chunk is transmitted via
POST /api/upload/chunkwith byte offset and total size headers. - The server writes chunks sequentially to disk in
data/uploads_temp/. - On completion, the file is assembled and moved to the user's storage directory with verified checksums.
- If the network drops, re-uploading checks the existing chunk count and resumes without re-transmitting sent bytes.
6. HTTP 206 Partial Content Streaming
MyDrive implements RFC 7233 byte-range serving. Browsers send:
This allows instant forward and backward seeking in multi-hour 4K videos with zero buffering delays.
7. Phone Contacts Sync & vCard
MyDrive provides a built-in contact manager directly in the browser:
- Native Phone Contact Picker: On mobile Chrome / Edge, tap "Sync Phone Contacts" to use
navigator.contacts.selectwithout installing native apps. - vCard 3.0/4.0 Support: One-click import and export of
.vcffiles. - CSV Spreadsheets: Export and import contacts with smart column header matching.
- Actionable Cards: Click-to-call (
tel:) and click-to-email (mailto:) links.
8. Enterprise Security & RBAC
- Argon2id Hashing: Passwords hashed with high-memory cryptographic cost factors.
- Path Traversal Defense: All file paths pass through
resolve_safe_path()which canonicalizes paths withos.path.realpath()to defeat directory traversal (../) and symlink breakout. - Double-Submit CSRF: Cryptographically signed tokens validate all
POST,PUT, andDELETEoperations. - HttpOnly Session Cookies: Cookies are invisible to client scripts, neutralizing XSS session hijacking.
- Brute-Force Lockout: Dynamic rate limiting locks accounts for 15 minutes after 5 consecutive failures.
9. REST API Reference
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/login | Authenticate user and set HttpOnly session cookie |
| GET | /api/files/list | List files & folders in directory with metadata |
| POST | /api/upload/chunk | Upload a 4MB binary slice of a streaming upload |
| GET | /api/files/stream | HTTP 206 Partial Content byte range media stream |
| POST | /api/shares/create | Create public or password-protected share token |
| GET | /api/health | Server uptime, memory utilization, and storage status |