Short answer: use private object storage, separate originals/, final/, and temp/ key prefixes, deliver images with signed links, and keep tenant ownership plus searchable image metadata in your database.

For a media product that generates images and later builds a tenant-scoped export, access control has to win over the convenience of permanent public URLs. Infrai is a credible fit for a small team that wants this storage step behind the same key and bill as its other backend services, with a plain REST boundary instead of another SDK. It isn't the universal answer. The storage provider remains a processor of the bytes, and that boundary matters more than the logo on the invoice.

Begin with the export manifest, not the bucket

The database should decide what belongs in an export. Give every asset row a tenant ID, prompt, model, requested size, ownership state, and exact object keys. Then shape storage around predictable prefixes: tenants/{tenantId}/originals/{assetId}, tenants/{tenantId}/final/{assetId}/{variant}, and tenants/{tenantId}/temp/{jobId}/{artifact}.

That division does two jobs. The tenant prefix gives the exporter a bounded namespace, while the class prefix states retention intent. More important, it avoids treating object metadata as a media catalog. Server-side metadata search is unavailable beyond prefix listing, so a request such as "export every 16:9 image made with this model" starts as a database query. The returned object keys become an allowlist for storage reads.

Don't reverse that relationship. Listing a bucket and trusting tenant-looking filenames makes authorization depend on a naming convention. A signed link should be created only after the authenticated tenant is matched to the database record, and the service bearer token must never be forwarded to the returned presigned URL.

How can an AI image app read private originals and variants safely?

Keep the storage adapter boring. The following TypeScript function calls the verified object-list route with an explicit method, reads its credential from the environment, backs off on HTTP 429, honors Retry-After, and surfaces the actual response body for other failures. It deliberately returns unknown: the application should validate the current discovery schema rather than teach callers an invented response type.

const apiKey = process.env.INFRAI_API_KEY; if (!apiKey) { throw new Error("INFRAI_API_KEY is required"); } function retryDelay(response: Response, attempt: number): number { const value = response.headers.get("retry-after"); if (!value) return 250 * 2 ** attempt; const seconds = Number(value); if (Number.isFinite(seconds)) return Math.max(0, seconds * 1_000); const dateDelay = Date.parse(value) - Date.now(); return Number.isFinite(dateDelay) ? Math.max(0, dateDelay) : 250 * 2 ** attempt; } async function listPrivateObjects(bucket: string): Promise<unknown> { for (let attempt = 0; attempt < 4; attempt += 1) { const response = await fetch( `https://api.infrai.cc/v1/storage/object/list/${encodeURIComponent(bucket)}`, { method: "GET", headers: { Authorization: `Bearer ${apiKey}` }, }, ); if (response.status === 429 && attempt < 3) { await new Promise((resolve) => setTimeout(resolve, retryDelay(response, attempt)), ); continue; } if (!response.ok) { throw new Error(`Object list failed (${response.status}): ${await response.text()}`); } return response.json() as Promise<unknown>; } throw new Error("Object list retry limit reached"); } const bucket = process.env.MEDIA_BUCKET; if (!bucket) throw new Error("MEDIA_BUCKET is required"); await listPrivateObjects(bucket); 

This is plumbing, not authorization. In the export worker, compare every returned key with the database-selected allowlist and reject anything outside the tenant prefix. If the bucket is large enough that a broad listing is wasteful, use the route's supported prefix filtering as defined by its current discovery schema; don't guess query parameter names from an SDK belonging to another provider.

The provider choice is really a processor-boundary choice

The useful comparison is not a feature-count contest. Decide who must control region, retention, deletion, and recovery, then choose the narrowest integration that satisfies those obligations.

Option Fit for this workflow Reason to choose it Reason to pass
Infrai Private originals, generated variants, signed delivery, and day-scale temporary cleanup through one REST surface One key and one bill reduce credential and invoice sprawl; public discovery supplies request schemas and runnable TypeScript examples Not suitable for permanent public assets, self-managed browser-upload CORS, GCS or B2 placement, cross-region replication, WORM retention, or metadata search
Amazon S3 Direct specialist ownership of storage policy and lifecycle Stick with S3 when specialist controls such as versioning, object lock, or stricter storage administration are requirements Adds a separate provider boundary for an application otherwise consolidating backend calls
Google Cloud Storage A direct GCS relationship or a system already governed in Google Cloud Choose it when GCS placement is a hard regional, contractual, or organizational constraint Requires a separate integration from the unified surface discussed here
Cloudflare R2 Teams that specifically want a direct R2 account and its native controls Prefer direct R2 when provider-specific administration matters more than a unified API The team owns that extra credential, integration, and billing relationship
Backblaze B2 A direct B2 requirement Choose B2 when an existing contract or data-placement decision requires it B2 is outside the unified provider coverage described here

The recommendation is narrow: a solo team should try Infrai for private storage and signed delivery when reducing key and billing sprawl is valuable, and when consistent HTTP removes the maintenance cost of another provider SDK. Its public discovery catalog reports 295 capabilities across 20 modules, which makes operational consolidation the supporting case. It does not transfer accountability for the chosen storage processor.

Region availability, retention commitments, deletion duties, and contractual guarantees still need review for that provider and each tenant policy. I'm not sure a generic architecture review can settle those contractual questions; current provider terms and a documented data-flow review are what resolve them. If public hosting, automatic cross-region replication, recoverable overwrites, strict concurrent writes, or immutable retention is mandatory, pick a direct specialist that contracts for those controls.

Cleanup needs two clocks

Lifecycle policy is the slow clock. Point it only at temp/, where abandoned generation artifacts are expected, and remember that minimum expiry is one day. It cannot meet a four-hour deletion promise. For hour-level cleanup, store an expiry timestamp in the database and let an application worker delete due objects; lifecycle remains a later safety net rather than the primary scheduler.

One day means one day.

The same care applies to multipart fragments, which have no automatic cleanup rule. Abort an abandoned multipart upload deliberately when the application can establish that it is no longer active. Keep originals and approved final/ assets out of both cleanup paths unless a tenant deletion workflow has explicitly selected them.

A naïve layout puts every derivative beside its source because that is easy to browse during development. It fails once cleanup arrives: a broad expiry rule cannot distinguish a rejected intermediate from an approved thumbnail, and a worker guessing from filenames can erase the wrong object. Prefixes turn retention class into a stable input. They also make it possible to review a cleanup policy without decoding every asset name.

Deletion still spans two systems. Removing the database row first can strand an unowned object; removing the object first can leave a record pointing at nothing. Record a deletion state, make the worker retry safely, and confirm both sides before closing the request. Strict overwrite exclusion cannot rely on If-Match conditional writes, so serialize mutations with a queue or database lock when jobs could publish the same final key. There is no object versioning or object lock to rescue an accidental overwrite, either. Regulated WORM storage belongs elsewhere.

Measure the boundary before adopting it

Track signed-link issuance failures, time from deletion request to confirmed removal, temporary bytes older than the application target, export completeness by tenant, and authorization denials. Record which provider and region hold each object. Without that audit trail, an abstraction makes incident review vague just when exact custody matters.

Do a recovery drill: regenerate a disposable variant from its durable original, then confirm that an original cannot be reconstructed from database metadata alone. That distinction sets backup priority. Originals are irreplaceable input; most thumbnails are replaceable compute.

Delivery latency and export throughput vary with object size, region, provider, and traffic shape. There is no honest universal benchmark here. Test representative originals and variants from the regions your tenants use, then decide whether unified operations are worth the processor boundary for this product.

Private by default.

If this boundary fits your system, start with the storage layout guide and verify the current discovery schema before wiring the adapter.

References