2.0 beta is ready. Install with @beta.
dimah-s3v1.7.2
Database

Database Lifecycle Hooks

Automatic lifecycle synchronization and ownership checks from @dimah-s3/db.

The db() plugin automatically attaches guards and synchronization actions across upload, download, and delete flows.

Access and scope validation

Route membership is still the server keyPrefix check (INVALID_KEY). These plugin guards do not compare the stored route column to the request route. They look up the row by (bucket, key) and compare scope.

Before an operation runs, @dimah-s3/db resolves the active session scope through resolveScope(request, context). context carries the operation, the route, and the object key the endpoint already validated (see scope context):

SituationResponse StatusError Code
resolveScope returns null401 UnauthorizedUNAUTHORIZED
Target key belongs to another scope403 ForbiddenFORBIDDEN
Target object row not found or soft-deleted404 Not FoundOBJECT_NOT_FOUND

Lifecycle behavior by operation

  • Upload — Upserts a pending row on presign / multipart init.
  • Upload confirmation — Verifies pending state (or refreshes an already-active overwrite), records verified contentLength from HeadObject, and returns the active row.
  • Download — Enforces that the object has status: "active" and matches the caller's scope.
  • Delete — Runs S3 DeleteObjectCommand, then updates row status to "deleted" (soft delete) or removes it (hard delete). A pending row whose object never landed is cleaned up too, so it stops counting toward quota. A pending multipart upload is aborted by its uploadId first.

Frequently asked questions

On this page