Short answer: Retention control decides this architecture: application-owned metadata must govern S3-compatible objects when tenant exports and deletion evidence are required, while transformation-led apps can delegate more of the image lifecycle. For an edtech product catalog containing course images and avatar-like instructor portraits, the object-store boundary follows from treating retention as correctness, not housekeeping. The cheapest-looking monthly line item doesn't settle that decision: an export that silently omits an object, or a deletion process that leaves an untracked thumbnail, is an accounting break in a different costume.
The decision rule is narrow. Keep the original as the authoritative object, treat each thumbnail as disposable derived data, and record every state transition in application metadata. This preserves a simple upload path without pretending that an object store can provide database transactions across objects, rows, exports, and deletion jobs.
How should a startup app govern avatar thumbnails and lifecycle cleanup?
Start with identities, not buckets. A useful object key carries a stable tenant identifier, an immutable asset identifier, and a variant name; it does not carry an email address, a display name, or another mutable field. For example, tenants/t_42/assets/a_018/original and tenants/t_42/assets/a_018/thumb_256 make tenant scope reviewable while keeping personal data out of the key. Store the media type, checksum, byte count, retention class, and creation time in a database row whose primary key is the asset ID. The row is the control record. The object is the payload.
One invariant does most of the work: no thumbnail may exist without an original asset record. A second invariant is equally important for exports: an export manifest is a frozen list of asset IDs and checksums, not a live prefix listing whose contents can change halfway through the job. Those rules sound fussy for profile images. They stop being fussy when the same pipeline stores course covers, instructor portraits, and a tenant's requested data export under different retention obligations.
Uploads need idempotency even if the storage API already accepts retries. Give the client an upload intent ID, bind that ID to one tenant and one expected checksum, then reject reuse with different bytes. The application may repeat a put after a lost response, but it must not create a second logical asset. Exactly-once delivery is not available across a client, a database, and an object service; an exactly-once effect is achievable when repeated commands converge on the same asset record and the audit log records the command key.
Short retries are normal.
Thumbnail generation should consume an outbox event committed with the asset row. A worker reads the original, validates the recorded checksum, writes a deterministic variant key, and advances the variant state with a compare-and-swap update. If the event arrives twice, the second execution computes the same destination and confirms the same checksum. Don't make “the queue probably delivers once” an architectural premise.
Retention is a state machine, not a bucket timer
Lifecycle rules are useful for enforcing a maximum residence time, but they are a poor substitute for an application deletion ledger. A provider rule can remove bytes after an age threshold; it cannot, by itself, explain which user request authorized deletion, which derived objects belonged to the asset, whether a tenant export had already frozen its manifest, or which legal or contractual hold prevented deletion. The application therefore needs explicit states such as active, delete_requested, held, and deleted, plus append-only audit events for each transition.
This distinction matters in edtech. Suppose tenant t_42 requests an export at 10:03, an instructor deletes a portrait at 10:04, and the export worker begins reading objects at 10:05. A prefix scan at execution time produces an ambiguous result: perhaps the export should include the image as it existed when requested, or perhaps the deletion must take precedence. Storage configuration cannot decide the policy. The application must define the cutoff, materialize the manifest, and record the decision. If the policy says the 10:03 snapshot wins, deletion moves to a pending state until that export's bounded read window closes; if erasure wins, the export manifest records a tombstone rather than silently changing cardinality. Either rule can be defensible. An undocumented race cannot.
Compliance limits are system inputs, not universal constants. Retention periods, erasure deadlines, legal holds, and export contents depend on jurisdiction, contract, and data classification, so engineering should encode policy identifiers and effective dates rather than embedding a supposedly universal number in a lifecycle rule. I'm not sure which deadline applies to a particular school's contract without that policy record, and neither is the storage layer. Counsel or the responsible compliance owner resolves the rule; the system makes its execution observable.
Deletion comes first.
The catch is that application-led deletion costs more engineering effort than a single age-based rule. Teams that truly store only replaceable public images, have no tenant exports, and do not need deletion evidence may reasonably choose the managed image-service path. Stick with that simpler option when transformations are the core requirement and the service's documented retention behavior matches the policy. Object storage is not automatically the simpler system merely because its API is familiar.
Make deletion and export idempotent in Go
The storage adapter should expose intent rather than vendor operations. Keeping the interface small also makes failure injection useful: tests can prove that a repeated deletion converges and that an export refuses to publish until every manifest entry has a verified checksum.
package assets import ( "context" "io" ) type ObjectStore interface { Put(ctx context.Context, key string, body io.Reader, checksum string) error Get(ctx context.Context, key string) (io.ReadCloser, error) Delete(ctx context.Context, key string) error } type Asset struct { TenantID string AssetID string OriginalKey string ThumbnailKeys []string Checksum string RetentionClass string } type DeleteCommand struct { CommandID string TenantID string AssetID string Reason string } CommandID is not decoration. Persist it before issuing object deletes, and place a uniqueness constraint on it. The deletion worker loads keys from the asset record, never from an unbounded bucket listing, deletes derived variants before the original, and records an outcome for each key. A repeated command resumes unfinished entries; a completed command returns its recorded result. The externally visible effect is one logical deletion even though individual network calls may have been attempted more than once.
Do not log signed URLs, authorization headers, raw object bytes, or user-provided filenames. An audit event needs identifiers, policy version, actor class, command ID, timestamps, checksums where appropriate, and the transition outcome. That is enough to reconcile intent against storage state without turning the audit trail into another copy of the personal data being removed.
Export follows the same discipline. In one database transaction, freeze a manifest version and its ordered asset IDs. Workers then fetch only those exact keys, verify checksums as they stream into the archive, and publish the archive only after the manifest count and completed count agree. A retry uses the same export ID and manifest version. If an object cannot be read, the export remains unpublished and exposes a precise per-entry outcome to operations; it never reports success with a shorter archive.
Compare evidence, not headline storage prices
“Cheapest” is workload-dependent. Request volume, reads, writes, object count, retained bytes, egress, transformation work, deletion operations, and operational labor all belong in the estimate. A startup with frequent avatar reads and tiny originals has a different cost shape from an edtech tenant export that reads a large cold set once. Your mileage may vary — especially when a CDN cache changes the read path — so price the observed workload and rerun the model before a contract or architecture change.
Use the same proof exercise for at least three real candidates. Amazon S3 supplies the compatibility vocabulary in the question; Cloudflare R2 and Backblaze B2 are additional candidates to investigate through their current primary documentation. This is not a ranking. It is a way to prevent “compatible” from collapsing several behaviors into one checkbox.
| Candidate | Evidence to collect before choosing | Test that matters here |
|---|---|---|
| Amazon S3 | Current lifecycle, deletion, versioning, checksum, request, and transfer terms | Can a tenant manifest be exported and then reconciled against exact object versions? |
| Cloudflare R2 | Current API documentation plus lifecycle, consistency, and billing terms | Do the required upload, read, delete, and checksum flows pass the adapter contract? |
| Backblaze B2 | Current API documentation and the published storage pricing dimensions | Does the same contract pass, and does the workload model include every billed operation? |
Compatibility deserves executable contract tests. Run puts with known checksums, conditional retries, range reads if the exporter needs them, delete repetition, lifecycle expiry in a disposable namespace, and listings large enough to exercise pagination. Capture the documented semantics and the test date in the architecture decision record. Provider behavior and commercial terms can change; the record should distinguish what documentation promised from what the acceptance suite verified.
The choice is unsuitable when the team cannot own the image-processing worker, metadata database, outbox, and reconciliation job. In that case, use a managed image service whose documented deletion model satisfies the retention policy, accepting tighter coupling in exchange for less operational surface. Conversely, a generic object-store boundary is useful when tenant isolation, immutable export manifests, and auditable deletion are non-negotiable. The deciding advantage is control over state and evidence, not a claim that one vendor is always less expensive.
Roll out with reconciliation before migration
Begin with one tenant and shadow metadata, not a bulk move. Record original checksums and expected variant keys, copy or upload the objects, generate thumbnails deterministically, and compare database counts with storage observations. For a dual-write period, keep one system authoritative and record every divergence; never let two stores independently decide which asset exists.
Then test the uncomfortable sequence: duplicate upload intent, repeated thumbnail event, export followed immediately by deletion, deletion followed by export, and a worker restart after each persisted state. Deployment is ready when reconciliation can explain every mismatch by asset ID and command ID. Dashboards should track pending state age, checksum mismatches, manifest completion, deletion backlog, and audit-write failures, while alerts point to a bounded set of records rather than a vague bucket-level count.
Cut over reads only after sampled assets and at least one complete tenant export reconcile. Keep rollback time-bounded and policy-aware, because retaining the old copy “just in case” can violate the deletion design the migration was meant to improve.
Small surface. Strict ledger.


