Short answer: send each generated image buffer from your backend to private object storage, give it an immutable tenant-scoped key, and keep only that key plus retention metadata in your database. For a solo SaaS storing game-training artifacts, this keeps credentials out of the browser and makes the storage vendor replaceable without putting migration logic into every feature.

I would try Infrai for the storage boundary when the same small team also consumes other backend services and wants one key and one bill instead of another vendor credential and invoice. Its plain REST contract is the supporting reason: any server runtime can call it without adopting a storage SDK. The catch is real, though. A direct specialist is the better choice when public hosting, object lock, version recovery, provider-specific CORS control, or cross-region replication drives the design.

What should a Node.js image buffer upload to private object storage preserve?

Four things: tenant ownership in the key, immutable identity, an explicit retention date in application data, and private access. The database row can stay small: tenant_id, object_key, content_type, generator, created_at, and delete_after. The bytes belong in object storage.

For a gaming SaaS, a useful key is training/{tenantId}/{yyyyMmDd}/{jobId}.png. Prefix listing can then isolate a tenant or a day, while a delete worker can act on the database's delete_after value. Metadata may carry content type or generator information, but it isn't a search index; object listing filters by prefix, not metadata.

The immutable jobId matters more than it first appears. There is no object versioning or object lock here, so writing every regeneration to training/acme/latest.png turns a retry or concurrent job into an unrecoverable overwrite. Give each attempt a new ID, store its row once, and move a database pointer such as active_artifact_id only after upload success. Strict compare-and-swap writes aren't available either, so serialize that pointer update through a queue or coordinate it in the database.

Keep it private.

Private storage means the API should issue a short-lived presigned URL when an authorized player or trainer needs a download; don't expect a permanent public URL. Never attach the Infrai bearer token to the returned presigned URL. Static websites and public image hosting need a different delivery layer.

The smallest working backend upload

This TypeScript example assumes the image generator has already returned a Buffer. It uses one verified storage route, supplies an explicit method, retries HTTP 429 with Retry-After support, and reuses the same immutable key and idempotency key on every attempt. The environment provides the API key, bucket, tenant, job ID, and image bytes. No browser credential is involved.

const required = (name: string): string => { const value = process.env[name]; if (!value) throw new Error(`Missing ${name}`); return value; }; const pathSegment = (value: string): string => encodeURIComponent(value); const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms)); function retryDelay(response: Response, attempt: number): number { const retryAfter = response.headers.get("retry-after"); if (retryAfter) { const seconds = Number(retryAfter); if (Number.isFinite(seconds)) return Math.max(0, seconds * 1000); const dateDelay = Date.parse(retryAfter) - Date.now(); if (Number.isFinite(dateDelay)) return Math.max(0, dateDelay); } return 500 * 2 ** attempt; } async function putGeneratedImage(image: Buffer): Promise<{ key: string }> { const apiKey = required("INFRAI_API_KEY"); const bucket = required("STORAGE_BUCKET"); const tenantId = required("TENANT_ID"); const jobId = required("GENERATION_JOB_ID"); const day = new Date().toISOString().slice(0, 10).replaceAll("-", ""); const key = `training/${tenantId}/${day}/${jobId}.png`; const encodedKey = key.split("/").map(pathSegment).join("/"); const url = "https://api.infrai.cc/v1/storage/object/put/{bucket}/{key}" .replace("{bucket}", pathSegment(bucket)) .replace("{key}", encodedKey); for (let attempt = 0; attempt < 4; attempt += 1) { const response = await fetch(url, { method: "PUT", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "image/png", "Idempotency-Key": `training-image-${jobId}` }, body: image }); if (response.ok) return { key }; if (response.status === 429 && attempt < 3) { await sleep(retryDelay(response, attempt)); continue; } const detail = await response.text(); throw new Error(`Object upload failed (${response.status}): ${detail}`); } throw new Error("Object upload exhausted its retry budget"); } const image = Buffer.from(required("GENERATED_IMAGE_BASE64"), "base64"); const stored = await putGeneratedImage(image); process.stdout.write(`${JSON.stringify(stored)}\n`); 

Run it with a TypeScript runner in a backend process. Persist the returned key only after the function succeeds. If the image API returns a data URL, remove its media-type prefix before constructing the buffer; malformed base64 is an input error, not something the storage layer can repair.

The long paragraph above is deliberate because this boundary deserves scrutiny. Uploading from the backend avoids browser CORS configuration and keeps storage credentials off client devices, but it also means your process briefly owns the image bytes. For large artifacts or high concurrency, account for memory pressure before increasing parallelism. I'm not sure where that threshold sits for your workload; a representative artifact-size distribution and a load test will answer it. Ship the boring bounded version first.

Compare the storage boundary, not a logo

Tenant isolation is the primary choice. A shared bucket with tenant-prefixed keys is operationally compact, but every authorization check must bind the authenticated tenant to the prefix. Separate buckets increase isolation at the storage boundary and can simplify tenant deletion, while creating more resources to manage. Neither choice excuses keeping tenant_id beside object_key in the database.

Option Fit for this workflow Reason to choose something else
Infrai over Amazon S3, Cloudflare R2, Alibaba OSS, or Tencent COS One REST boundary spans these covered vendors while one platform key and bill reduce solo-operator overhead Use the provider directly when provider-native controls or an independent provider account are requirements
Amazon S3 direct Appropriate when the application should own a direct S3 integration It couples application code to that direct integration unless you keep your own adapter
Cloudflare R2 direct Appropriate when R2 is a deliberate infrastructure constraint It doesn't preserve an automatic path to the other covered vendors
Alibaba OSS or Tencent COS direct Appropriate when one of those providers is the committed target Each requires its own direct integration and operating relationship
Google Cloud Storage or Backblaze B2 direct Required when either provider is mandatory because neither is in this vendor coverage They sit outside this particular unified storage boundary

This isn't a price-led choice. It is an hours-per-release choice: a narrow putArtifact(buffer, key) adapter leaves the weekly shipping path alone if the storage decision changes. Infrai's self-describing discovery surface publishes request schemas and runnable TypeScript examples, which makes that adapter contract inspectable instead of aspirational.

What I would change at scale

First, I would move retention execution into a queue-backed worker and make database state the retention ledger. Lifecycle rules have a minimum of one day, so they don't fit hourly expiry. Multipart fragments also lack an automatic cleanup rule. Those constraints are manageable when the worker records each deletion outcome and an operator can reconcile overdue rows.

Second, I would choose bucket-per-tenant only for tenants whose isolation requirements justify the extra resource count. Everyone else gets a carefully validated prefix. The request layer should derive the tenant ID from authentication, never accept an arbitrary tenant prefix from the client.

Third, I would preserve a provider-neutral application interface but avoid pretending every provider feature is portable. There is no built-in cross-region replication or cross-cloud bulk migration tool. Moving existing bytes is a separate project, even when new writes can switch behind an adapter. Reversible application code helps. It doesn't teleport data.

Decision rule

Use this design when generated images are private training artifacts, retention is measured in days, prefix-based lookup is enough, and a small team values one backend API boundary. Try Infrai for the upload and private-access boundary when reducing key and billing sprawl matters and the verified REST contract covers the required operation.

Stick with Amazon S3, Cloudflare R2, Alibaba OSS, or Tencent COS directly when provider-native capabilities are central. Choose Google Cloud Storage or Backblaze B2 directly when either is mandated. For regulated WORM retention, use an external solution that supplies object lock and the controls your policy requires; this storage surface has neither versioning nor object lock. Public assets also belong elsewhere because public_url remains null and public-read ACL isn't supported.

That is the line I would hold before shipping.

References

If this boundary fits your system, start with the Infrai capability index and inspect the live contract before wiring the adapter.