|
3 | 3 | FastAPI-powered micro CDN for storing and serving uploaded assets. Files are written to disk, indexed with SQLModel, and delivered with CDN-friendly cache headers plus live usage stats on the landing page. |
4 | 4 |
|
5 | 5 | ## Features |
6 | | -- Public upload and listing endpoints with UUID-based storage. |
| 6 | +- Public upload and listing endpoints with compact base62 slugs (Telegraph/ImgBB style URLs). |
7 | 7 | - 10 MB per-file upload cap with friendly error responses. |
8 | 8 | - In-memory rate limiting (per-client/minute) to prevent abuse. |
9 | 9 | - Automatic cleanup job that prunes files after the configured retention window. |
@@ -37,6 +37,7 @@ Optional environment variables: |
37 | 37 | | `CACHE_MAX_AGE_SECONDS` | `3600` | Cache lifetime used for served files. | |
38 | 38 | | `ADMIN_PASSWORD` | `admin-dev-password` | Password required to access the `/admin` dashboard. | |
39 | 39 | | `ADMIN_LOCK_STEP_SECONDS` | `300` | Lock duration increment (in seconds) after repeated failed admin logins. | |
| 40 | +| `FILE_ID_LENGTH` | `7` | Length of generated slug IDs (min 4, max 32). | |
40 | 41 |
|
41 | 42 | Run the API: |
42 | 43 |
|
@@ -88,9 +89,9 @@ Key environment variables for production deployments: |
88 | 89 | | Method | Path | Description | |
89 | 90 | |--------|------|-------------| |
90 | 91 | | `POST` | `/upload` | Accepts multipart file upload (respecting the configured size limit) and returns metadata (`id`, `url`, `size`, `type`). | |
91 | | -| `GET` | `/{filename}` | Serves a stored file by UUID filename and includes `Cache-Control` headers. | |
| 92 | +| `GET` | `/{filename}` | Serves a stored file by slug filename and includes `Cache-Control` headers. | |
92 | 93 |
|
93 | | -Returned `url` values are relative (e.g. `/3d4d...jpg`), suitable for prefixing with your CDN/API host. |
| 94 | +Returned `url` values are relative (e.g. `/aB7xYzQ.jpg`), suitable for prefixing with your CDN/API host. |
94 | 95 |
|
95 | 96 | ### Admin Dashboard |
96 | 97 | - Visit `/admin` with the header `X-Admin-Password: <ADMIN_PASSWORD>` (or include `password` in the query/form) to view uploads, downloads, cleanup counts, recent files, and trigger per-file or bulk deletions. |
|
0 commit comments