File storage
S3-compatible storage or Supabase Storage, behind one StorageProvider interface.
Choose with --storage s3 (default), --storage supabase (needs Supabase Auth), or --storage none. On a React + Vite frontend with an API, the Hono and FastAPI APIs implement every option: see A frontend and its API.
The storage adapter works with AWS S3 and S3-compatible providers such as Cloudflare R2 and MinIO. Configure STORAGE_BUCKET, STORAGE_REGION, STORAGE_ENDPOINT when required, and the access key, secret, and optional public URL. For R2, use the account's S3 API endpoint and region auto.
Locally, Docker local services run an S3-compatible server with the bucket app. Without Docker, uploads go to a local folder while STORAGE_DIRECTORY is set.
The storage adapter does not authorize users or validate uploads. Before calling it, the route must check ownership and authorization, file size, content type, and the object key. Keep credentials server side.
A frontend and its API
With the Hono API (Starter v0.25.0 or newer) and the FastAPI API (Starter v0.26.0 or newer), the API holds the storage adapter. Set its variables in apps/api/.env.local, and in a route:
- Hono: call
getStorage(c.req.raw)fromapps/api/src/server/storage.ts. - FastAPI: call
get_storage(request)fromapps/api/src/clubedge_api/storage.py, then await itsupload,download,delete,exists, orget_signed_url.
With either API:
- S3-compatible: with
--infra local, files go to the folder inSTORAGE_DIRECTORY, relative to the API.pnpm check:servicesuploads, reads back, and deletes a test file. - Supabase Storage: the adapter acts as the user whose Supabase access token the request carries (the
Authorization: Bearerheader the frontend sends), and as anonymous without one.
How is this guide?