Server
Backend handlers, route policies, and lifecycle hooks for S3 file flows.
@dimah-s3/server presigns
uploads and downloads, enforces route constraints, runs your guards, and calls
your lifecycle hooks.
Uploads, and by default downloads, go straight between the browser and the bucket through short-lived signed URLs. Downloads can instead stream through your server in proxy mode. S3 credentials stay on the server, and deletes run there too.
Key features
- One instance —
dimahS3()returns an HTTPhandler, an in-processapiwith the browser client's shape, andputfor server-side uploads. - Server-owned keys — The browser sends a route name. The server builds the object key.
- Upload tickets — Presign returns a signed ticket. Confirm and every later multipart call send only that ticket, optionally bound to a user.
- HeadObject verification — Confirm reads the stored size and type from S3, not from the browser.
- Guards and locals — Guards authorize each call and can pass typed
localsto later hooks. - Hardened proxy —
GET /filestreams objects with a sandbox CSP, single-range support, and conditional requests. - Framework adapters — Next.js, Hono, Express, Fastify, SvelteKit, Elysia, Node, and any Fetch runtime.
Documentation
Server Setup
Install, set the ticket secret, and mount the handler.
Routes
Configure routes, file constraints, operations, and key prefixes.
Security
Guards, key isolation, tenant scoping, and metadata validation.
Upload Tickets
The signed ticket behind confirm and multipart, and its secret.
File Proxy
Stream downloads through GET /file with Range and caching.
Errors
The error catalog, s3Error, and client mapping.
Lifecycle Hooks
Start, confirm, download, delete, and multipart hooks.
Plugins
Extend the server with hooks, endpoints, and context.