Short answer: Store generated images and thumbnails in private object storage, using immutable object keys and a database retention ledger. Generate each tenant export from that ledger, issue short-lived signed access only after authorization, and delete originals plus derivatives from one explicit manifest. The storage bill matters, but a cheap byte that cannot be found and erased is expensive engineering.
| Choice | Deletion evidence | Export consistency | Operating burden | Fit |
|---|---|---|---|---|
| Object store + retention ledger | Per-object state and timestamps | Snapshot from recorded rows | Moderate | Default |
| Object store + key-prefix scans | Inferred from listing results | Can drift during a scan | Low at first | Small, disposable workloads |
| Database binary columns | Transactional row deletion | Strong for modest objects | High database load | Small, tightly coupled sets |
| Managed media pipeline | Depends on its deletion model | Depends on its export surface | Low application effort | Transformation-heavy teams |
Recommendation: choose the ledger design for a multi-tenant logistics product. It makes retention a product rule rather than a bucket convention. Keep originals and thumbnails private, store their relationship in one row set, and treat lifecycle rules as a backstop rather than the primary deletion workflow.
I use a revenue-per-hour lens for infrastructure: spend engineering time on tenant boundaries and provable deletion, then outsource undifferentiated byte durability and image delivery. That trade-off supports weekly shipping without pretending cleanup is automatic.
How should logistics apps store generated images and thumbnails?
A logistics tenant may have product images attached to catalog items, shipment records, or both. The export must answer a precise question: which objects belonged to this tenant at the export cutoff? A recursive prefix listing answers a different question: which keys are visible when the scan happens. Uploads and deletions can continue while that scan runs.
The ledger should therefore carry ownership and time explicitly. At minimum, record tenantId, a stable asset ID, the original key, every derivative key, creation time, retention deadline, and deletion state. Build an export from a database snapshot or an equivalent fixed cutoff. Do not infer tenancy from a user-supplied path.
The key can still help operators read logs. A shape such as tenants/{tenantId}/assets/{assetId}/original is useful, but it is an address, not authorization. The application must establish tenant ownership before it signs any read.
Short-lived signed access limits how long a granted URL remains useful. It does not revoke a file already downloaded, and it does not prove that the underlying object was deleted. Keep those jobs separate. For a downloadable export, set a safe filename through the HTTP Content-Disposition response header; MDN documents the attachment directive and filename parameters.
Criterion one: deletion is a state machine
Deletion should have named states because storage and database changes do not share one transaction. A practical sequence has three: active to delete_pending to deleted. The request that starts erasure marks rows first. A worker removes every key in the stored manifest, confirms the result according to the storage interface, and then records completion. Retries must be harmless. Deleting only the original leaves thumbnails behind, and deriving thumbnail names later is fragile because transformation versions change. Store derivative keys when they are created. One asset may have a 256-pixel preview today and another size after next week's release; both still need deletion. Keep tombstones or deletion audit records for the period required by your own compliance policy, but do not keep the erased image inside that record. GDPR Article 17 establishes a right to erasure under stated conditions and also lists exceptions. Product counsel must translate those conditions into the retention policy; an infrastructure lifecycle timer cannot make that legal decision. A timeout after a delete call leaves the outcome uncertain, so retry the same object key. A missing object can count as the desired terminal storage state, while permission failures and malformed keys need operator attention. Only mark the asset deleted after its whole manifest reaches the terminal state.
Retries happen.
Criterion two: exports need a frozen manifest
Create an export job with a cutoff time and materialize the included asset IDs. Then produce an archive or manifest from that fixed set. If a deletion request arrives during generation, policy must decide which wins; encode that decision instead of letting worker timing decide it.
For many SaaS products, the clean rule is to reject new access once an asset becomes delete_pending, while an already-created export job either completes from its frozen manifest or is canceled and rebuilt. Pick one rule and test it. Ambiguity here creates the worst kind of support ticket: both outcomes look plausible.
The export should contain tenant-owned records only and use neutral filenames rather than raw object keys. Object keys can expose internal identifiers and layout decisions. If clients download individual files instead of one archive, authorize each asset before minting its signed URL and keep the expiry short enough for the workflow, not indefinitely convenient.
A small TypeScript boundary
The useful abstraction is not a vendor SDK wrapper with every storage feature. It is the narrow contract the retention worker needs.
type AssetState = "active" | "delete_pending" | "deleted"; type StoredAsset = { id: string; tenantId: string; keys: readonly string[]; state: AssetState; retainUntil: Date; }; interface PrivateObjectStore { delete(key: string): Promise<void>; signRead(key: string, expiresInSeconds: number): Promise<URL>; } interface AssetLedger { claimExpired(now: Date, limit: number): Promise<StoredAsset[]>; markDeleted(assetId: string, deletedAt: Date): Promise<void>; recordFailure(assetId: string, reason: string): Promise<void>; } async function purgeExpiredAsset( asset: StoredAsset, store: PrivateObjectStore, ledger: AssetLedger, ): Promise<void> { try { for (const key of asset.keys) { await store.delete(key); } await ledger.markDeleted(asset.id, new Date()); } catch (error) { const reason = error instanceof Error ? error.message : "unknown deletion error"; await ledger.recordFailure(asset.id, reason); throw error; } } The worker receives claimed rows in bounded batches. The claim mechanism should prevent two workers from treating the same row as fresh work, while idempotent deletion makes overlap survivable. Do not log signed URLs. Log the tenant ID, asset ID, attempt count, state transition, and a redacted error category.
Test the boundary with more than a happy path. Cover an original with two derivatives, a missing derivative, a permission failure halfway through the manifest, a repeated job, and two tenants with visually identical filenames. Add a clock-controlled test at the retention boundary. Then run a periodic reconciliation that compares ledger state with storage inventory and alerts on old delete_pending rows or untracked objects.
Ship the first version with one thumbnail size if that serves the product. The manifest model lets later transformations grow without rewriting the deletion contract. This is where I would protect weekly delivery: keep resizing asynchronous, cap retries, and expose queue age plus deletion age as operational signals. Fancy media features can wait.
When is the runner-up better?
Prefix scans are reasonable when the data is disposable, the tenant count is small, exports are rare, and deletion proof is not a requirement. They remove a table and a worker state machine. The trade-off is weaker control over snapshots and a harder reconciliation story. Put a low threshold on that shortcut; once users can request exports or erasure, migration becomes product work.
Database binary storage can be the better runner-up when objects are small, few, and inseparable from transactional rows. It gives a compact consistency model, but image traffic now competes with application queries, backups carry the bytes, and thumbnail growth expands the primary data system. Measure with the actual workload before accepting that coupling.
A managed transformation service fits when image operations are a major product surface and the service's tenant isolation, export, retention, and deletion semantics match the written policy. That is an outsourcing decision, not a shortcut around ownership. Keep an asset ledger anyway if the application must explain what was exported or erased. The limitation of the ledger design is its worker, reconciliation, and schema overhead; it is not a fit for a disposable prototype with no tenant export or erasure requirement.
The final selection rule is blunt: choose the option that can enumerate one tenant's assets at a fixed cutoff and drive every derivative to a recorded deletion state. Optimize byte cost after those statements are true. For a solo SaaS, predictable operations return more shipping time than a fragile minimum-price comparison.
