A self-hosted Google Drive alternative built with Rust and Next.js. Store and manage your files across multiple disks with a modern web interface.
- 🚀 Self-hosted - Complete control over your data
- 💾 Multi-disk support - Automatically distribute files across multiple storage devices
- 🔐 Secure authentication - JWT-based auth with Argon2 password hashing
- 📤 Chunked uploads - Support for large file uploads with progress tracking
- 🧹 Automatic cleanup - Smart temporary file management with scheduled cleanup
- 🌐 Modern UI - Clean, responsive interface built with Next.js and TailwindCSS
- 👥 User management - Admin panel for managing users and monitoring storage
- 🔗 File sharing - Generate shareable links with permissions
- 🌍 Multi-language - Support for English and Turkish
- ⚡ Real-time updates - WebSocket support for live upload progress
- 🖼️ File previews - Thumbnail generation for images and videos
- Rust with Axum framework
- PostgreSQL with SQLx
- JWT authentication
- Tokio for async operations
- Next.js 14 (App Router)
- TypeScript
- TailwindCSS
- Rust (latest stable)
- Node.js 18+ or Bun
- PostgreSQL 14+
- Git
git clone https://github.com/sw3do/local-drive.git
cd local-drivecd backend
# Copy environment file
cp .env.example .env
# Edit .env with your configuration
nano .envDATABASE_URL=postgresql://username:password@localhost:5432/localdrive
# Linux/macOS
STORAGE_PATHS=/path/to/storage1,/path/to/storage2
# Windows (use double backslashes)
# STORAGE_PATHS=C:\\storage,D:\\storage
PORT=3001
JWT_SECRET=your-super-secret-jwt-key-here# Install SQLx CLI
cargo install sqlx-cli
# Create database
createdb localdrive
# Run migrations
sqlx migrate run
# Build and run
cargo runcd ../frontend
# Copy environment file
cp .env.example .env.local
# Edit .env.local
nano .env.localNEXT_PUBLIC_API_URL=http://localhost:3001# Using npm
npm install
npm run dev
# Or using bun
bun install
bun devcd backend
# Create admin user
cargo run -- create-admin \
--username admin \
--email [email protected] \
--password your-secure-password# Connect to your PostgreSQL database
psql -d localdrive
# Update user role to admin
UPDATE users SET is_admin = true WHERE email = '[email protected]';# 1. First register a user via the web interface
# 2. Then update the user to admin in database
psql -d localdrive -c "UPDATE users SET is_admin = true WHERE email = '[email protected]';"# Linux/macOS
STORAGE_PATHS=/home/user/storage
# Windows
STORAGE_PATHS=C:\\storage# Linux/macOS
STORAGE_PATHS=/mnt/disk1,/mnt/disk2,/home/backup
# Windows (use double backslashes)
STORAGE_PATHS=C:\\storage,D:\\storage,E:\\backupFiles are automatically distributed across disks when the current disk becomes full.
POST /api/auth/login- User loginPOST /api/auth/register- User registrationPOST /api/auth/refresh- Refresh JWT token
GET /api/files- List user filesPOST /api/files/upload- Upload file (chunked)GET /api/files/:id/download- Download fileDELETE /api/files/:id- Delete filePOST /api/files/:id/share- Create share link
GET /api/admin/users- List all usersPOST /api/admin/users- Create userDELETE /api/admin/users/:id- Delete userGET /api/admin/storage- Storage statistics
cd backend
# Run with auto-reload
cargo watch -x run
# Run tests
cargo test
# Format code
cargo fmt
# Lint
cargo clippycd frontend
# Development server
npm run dev
# Type checking
npm run type-check
# Linting
npm run lint
# Build for production
npm run build# Build and run with docker-compose
docker-compose up -dcd backend
cargo build --release
./target/release/local-drivecd frontend
npm run build
npm startserver {
listen 80;
server_name yourdomain.com;
location /api {
proxy_pass http://localhost:3001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}POST /auth/login- User login
GET /files- List user filesGET /files/:id/download- Download fileDELETE /files/:id- Delete file
POST /upload/initiate- Start chunked uploadPOST /upload/:upload_id/chunk/:chunk_number- Upload chunkPOST /upload/:upload_id/complete- Complete uploadGET /upload/:upload_id/status- Get upload statusDELETE /upload/:upload_id/cancel- Cancel upload
GET /admin/users- List all usersGET /admin/storage- Get storage informationGET /admin/storage/report- Get detailed disk usage reportGET /admin/temp/info- Get temporary files informationPOST /admin/temp/cleanup- Clean orphaned temp files (24h+)POST /admin/temp/cleanup/:hours- Clean temp files older than specified hours
GET /user/storage- Get user storage info
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Required |
STORAGE_PATHS |
Comma-separated storage paths | ./storage |
PORT |
Server port | 3001 |
JWT_SECRET |
JWT signing secret | Required |
MAX_FILE_SIZE |
Maximum file size in bytes | 104857600 (100MB) |
CORS_ORIGINS |
Allowed CORS origins | http://localhost:3000 |
LOG_LEVEL |
Logging level | info |
| Variable | Description | Default |
|---|---|---|
NEXT_PUBLIC_API_URL |
Backend API URL | Required |
NEXT_PUBLIC_MAX_FILE_SIZE |
Max file size for uploads | 104857600 |
NEXT_PUBLIC_CHUNK_SIZE |
Upload chunk size | 1048576 |
-
Database connection failed
- Check PostgreSQL is running
- Verify DATABASE_URL in .env
- Ensure database exists
-
Storage permission denied
- Check directory permissions
- Ensure storage paths exist
- Verify disk space
-
Upload fails
- Check MAX_FILE_SIZE setting
- Verify available disk space
- Check network connectivity
-
Temporary files accumulating
- Automatic cleanup runs every 6 hours
- Manual cleanup via
/admin/temp/cleanupendpoint - Check temp directory permissions
# Backend logs
cd backend
RUST_LOG=debug cargo run
# Frontend logs
cd frontend
npm run dev- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Join our community discussions
- Mobile app (React Native)
- File versioning
- Advanced search and filtering
- Backup and sync features
- Plugin system
- Advanced admin analytics
- File encryption at rest
- Two-factor authentication
Made with ❤️ by sw3do