2025-08-02 00:18:09 +03:00
|
|
|
|
# Quoter 🚀
|
2023-10-03 16:29:31 +03:00
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
> Simple file upload proxy with quotas. Upload to S3, thumbnails via Vercel.
|
2023-10-03 16:29:31 +03:00
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
**Focus**: Upload + Storage. Thumbnails managed by Vercel Edge API for better performance.
|
2024-08-30 21:06:41 +03:00
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
## What it does
|
2024-08-30 21:06:41 +03:00
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
- 📤 **Upload files** to S3/Storj with user quotas
|
|
|
|
|
|
- 🔐 **JWT authentication** with session management
|
|
|
|
|
|
- 📦 **File serving** with caching and optimization
|
|
|
|
|
|
- 🌐 **CORS support** for web apps
|
2023-10-03 16:29:31 +03:00
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
## 🚀 Quick Start
|
2023-10-19 17:43:00 +03:00
|
|
|
|
|
2025-08-12 15:59:51 +03:00
|
|
|
|
```bash
|
2025-09-02 14:00:54 +03:00
|
|
|
|
# Setup
|
|
|
|
|
|
cargo build
|
|
|
|
|
|
cp .env.example .env # Configure environment
|
|
|
|
|
|
cargo run
|
2025-08-12 15:59:51 +03:00
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
# Test
|
|
|
|
|
|
curl http://localhost:8080/ # Health check
|
2025-08-12 15:59:51 +03:00
|
|
|
|
```
|
|
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
## 🔧 API
|
2025-08-02 00:18:09 +03:00
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
| Method | Endpoint | Description |
|
|
|
|
|
|
|--------|----------|-------------|
|
|
|
|
|
|
| `GET` | `/` | Health check or user info (need auth token) |
|
|
|
|
|
|
| `POST` | `/` | Upload file (need auth token) |
|
|
|
|
|
|
| `GET` | `/{filename}` | Get file or thumbnail |
|
2025-08-02 00:18:09 +03:00
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
### Upload file
|
2025-08-02 00:18:09 +03:00
|
|
|
|
```bash
|
|
|
|
|
|
curl -X POST http://localhost:8080/ \
|
|
|
|
|
|
-H "Authorization: Bearer your-token" \
|
|
|
|
|
|
-F "file=@image.jpg"
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
### Get thumbnail
|
2025-08-02 00:18:09 +03:00
|
|
|
|
```bash
|
2025-09-02 14:00:54 +03:00
|
|
|
|
# Legacy thumbnails (fallback only)
|
2025-08-02 00:18:09 +03:00
|
|
|
|
curl http://localhost:8080/image_300.jpg
|
2025-09-02 14:00:54 +03:00
|
|
|
|
|
|
|
|
|
|
# 💡 Recommended: Use Vercel Image API
|
|
|
|
|
|
https://yoursite.com/_next/image?url=https://files.dscrs.site/image.jpg&w=300&q=75
|
2025-08-02 00:18:09 +03:00
|
|
|
|
```
|
|
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
## 🏗️ Architecture & Setup
|
|
|
|
|
|
|
|
|
|
|
|
**Simple 3-tier architecture:**
|
|
|
|
|
|
- **Upload**: Quoter (auth + quotas + S3 storage)
|
|
|
|
|
|
- **Download**: Vercel Edge API (thumbnails + optimization)
|
|
|
|
|
|
- **Storage**: S3/Storj (files) + Redis (quotas/cache)
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
Upload: Client → Quoter → S3/Storj
|
|
|
|
|
|
Download: Client → Vercel → Quoter (fallback)
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
💋 **Simplified approach**: Quoter handles uploads, Vercel handles thumbnails.
|
|
|
|
|
|
|
|
|
|
|
|
## 📋 Environment Setup
|
|
|
|
|
|
|
2025-08-02 00:18:09 +03:00
|
|
|
|
```bash
|
2025-09-02 14:00:54 +03:00
|
|
|
|
# Required
|
|
|
|
|
|
REDIS_URL=redis://localhost:6379
|
|
|
|
|
|
STORJ_ACCESS_KEY=your-key
|
|
|
|
|
|
STORJ_SECRET_KEY=your-secret
|
2025-09-30 21:46:47 +03:00
|
|
|
|
JWT_SECRET_KEY=your-secret # Должен совпадать с @core
|
2025-09-02 14:00:54 +03:00
|
|
|
|
|
|
|
|
|
|
# Optional
|
|
|
|
|
|
PORT=8080
|
|
|
|
|
|
RUST_LOG=info
|
2025-08-02 00:18:09 +03:00
|
|
|
|
```
|
|
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
## 🧪 Testing
|
2025-08-02 00:18:09 +03:00
|
|
|
|
|
|
|
|
|
|
```bash
|
2025-09-02 14:00:54 +03:00
|
|
|
|
cargo test # 36 tests passing
|
|
|
|
|
|
./scripts/test-coverage.sh # Coverage report
|
2025-08-02 00:18:09 +03:00
|
|
|
|
```
|
|
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
## 📚 Documentation
|
2025-08-02 00:18:09 +03:00
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
- [`docs/configuration.md`](./docs/configuration.md) - Environment setup
|
|
|
|
|
|
- [`docs/architecture.md`](./docs/architecture.md) - Technical details
|
|
|
|
|
|
- [`docs/vercel-og-integration.md`](./docs/vercel-og-integration.md) - Vercel integration
|
2025-08-02 00:18:09 +03:00
|
|
|
|
|
2025-09-02 14:00:54 +03:00
|
|
|
|
For detailed setup and deployment instructions, see the docs folder.
|