Skip to main content
Use temporary staging when a file arrives before its final model exists. A lease binds private temporary bytes to a trusted owner, destination, expiry and content checksum. FLEX upload fields use this lifecycle automatically when staging is enabled.

Stage a file

Derive $owner from authenticated server context. A lease ID is not sufficient permission to read, promote or delete a file.

Promote after validation

confirm() belongs after your durable model reference is accepted. If you save inside a database transaction, confirm after its commit. A repeated successful promotion returns the same receipt instead of intentionally creating another file.

Create a Spatie attachment

The destination must retain the lease’s configured target and policy. Bind the newly saved record when promoting a create-form lease.

Check status

Use this in an authorized application flow. An ordinary form validation failure should leave pending data available for a corrected submission.

Abandon an unsaved file

Use explicit cancellation for abandonment. It does not delete an already committed permanent object. Browser close/unload is not relied on for cleanup; pending leases also have an expiry.

Read staged content in your service

DocumentInspection is an application-provided service. Do not retain a staged source beyond this callback.

Recover an interrupted promotion

If a promotion already has a durable receipt, retry can verify and complete that operation. If the outcome is ambiguous, locate the persisted object independently and reconcile it server-side:
Recovery checks the owner, operation, target, record and content. Do not reconstruct a receipt from untrusted browser input. A missing receipt is not proof that a write never happened.

Rollback in a custom persistence flow

Use this only when your save flow has genuinely rolled back the new attachment. unbindRecord: true lets a failed create attempt later bind a different saved record. FLEX fields provide their own rollback integration on connections supporting rollback callbacks.

Cleanup commands

The janitor removes expired/abandoned temporary data and old receipt metadata within its mutation budget. It preserves uncertain promotions for reconciliation. Livewire temporary uploads retain their own cleanup configuration. A programmatic sweep is also available:
Configure TTL, private disk, lock lifetime and batch size in Media OS configuration.

Form fields

This keeps staging while disabling the field’s automatic retry recovery. Field save/recovery guide.
Last modified on October 16, 2026