Database
Optional plugin to track object ownership, lifecycle, and listings in your database.
@dimah-s3/db is an optional
plugin for dimahS3. It keeps object ownership, upload
state, and deletion history aligned with S3 without custom SQL on every
endpoint.
dimah-s3 works without a database. Add this plugin when you need ownership checks, usage totals, file listings, or server-side multipart lifecycle tracking.
What the plugin does
- Tracks objects — writes and updates a row on presign, confirm, and delete
- Enforces ownership — each file belongs to a scope you define (for example
user:123); download requires a confirmed (active) object owned by that scope; delete rejects access from another scope. This is per-caller tenancy, not the routekeyPrefixcheck — prefix isolation always runs in@dimah-s3/server. - Lists files — query by scope on the server and in the browser
- Tracks multipart — records in-progress uploads for ownership and stale
cleanup; pair it with a client
UploadStoreto resume after the same local file is reselected
Authentication, quota values, and business rules stay application-owned. The plugin manages object metadata and scope isolation, and can compare usage with limits supplied by your application.
Lifecycle
Each object moves through three statuses:
| Status | Meaning |
|---|---|
pending | Upload started, not confirmed |
active | Confirmed in S3 — verified size stored |
deleted | Removed from S3 |
Typical flow: pending → active → deleted. Aborted multipart uploads and
purge clean up rows that never reached active.
Next steps
Database Setup
Install, add the schema, and register the plugin.
Database Lifecycle Hooks
Lifecycle hooks the plugin attaches automatically.
API
List and query objects from server or browser.
Purge Stale Uploads
Remove stale pending uploads.
Full example
Minimal Next.js + Drizzle setup with upload and listing.