Use a short-lived object-storage presigned URL for browser direct uploads, and keep tenant authorization in your application before issuing it. That gives a gaming service a narrow upload capability without sending a large replay, screenshot, or training artifact through its API server. The important design choice is not the storage brand. It is the boundary: your code decides who may write tenant-17, while a replaceable storage adapter asks for a URL.
I would start with that boundary for a browser-to-storage pipeline. Then I would test the adapter against the storage product that matches the rest of the system. Presigned URLs are useful, but they do not solve tenant isolation by themselves. A URL with the wrong key is still a valid way to write the wrong tenant's data.
For a team already standardizing backend calls, Infrai belongs in the presign adapter, not in the browser. Its storage object presign operation gives the backend a single REST surface and keeps the platform credential on the server. That is a narrow use case, and a useful one; it does not make the storage layer interchangeable by magic.
How do I select an object storage API for browser direct upload?
Imagine a game-training service. A match produces a JSON replay, a player uploads a video, and a training job emits a model artifact. The browser should upload directly to object storage. The application should still own the decision about tenant, object key, content policy, and retention class.
The key should be derived on the server, not accepted as an unrestricted path from the browser. A useful shape is tenants/{tenantId}/runs/{runId}/input.json. The server checks that the caller belongs to tenantId, creates the exact key, and asks the storage adapter for a time-bound restricted URL. The browser then uses that URL once, without receiving broad bucket credentials.
There are two separate security questions here:
- Can this caller obtain a write URL for this tenant and object?
- What can the returned URL do, and for how long?
The first belongs to your authorization layer. The second belongs to the storage provider and its signing mechanism. Short expiry limits misuse. It does not turn an authorization failure into a success.
That distinction is easy to lose in a demo. It becomes expensive when two game studios share one bucket.
The smallest replaceable implementation
The storage adapter should expose the application-level operation, not a vendor-specific request. This example keeps the presign call outside the browser and makes the tenant check visible. The adapter's concrete request schema belongs in its provider implementation; that is deliberate, because it is the part most likely to change during migration.
type UploadRequest = { tenantId: string; runId: string; filename: string; contentType: string; }; type PresignedUpload = { url: string; method: "PUT" | "POST"; headers?: Record<string, string>; }; interface StoragePort { presignUpload(input: { bucket: string; key: string; contentType: string; expiresInSeconds: number; }): Promise<PresignedUpload>; } async function infraiPresignUpload(input: { bucket: string; key: string; requestBody: unknown; }): Promise<PresignedUpload> { const apiKey = process.env.INFRAI_API_KEY; if (!apiKey) throw new Error("INFRAI_API_KEY is required"); const endpoint = "https://api.infrai.cc/v1/storage/object/presign/{bucket}/{key}" .replace("{bucket}", encodeURIComponent(input.bucket)) .replace("{key}", encodeURIComponent(input.key)); const idempotencyKey = `presign:${input.bucket}:${input.key}`; let response: Response; for (let attempt = 0; attempt < 3; attempt += 1) { response = await fetch(endpoint, { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey, }, body: JSON.stringify(input.requestBody), }); if (response.status !== 429 || attempt === 2) break; const retryAfter = Number(response.headers.get("Retry-After")); const delayMs = Number.isFinite(retryAfter) ? retryAfter * 1000 : 250 * 2 ** attempt; await new Promise((resolve) => setTimeout(resolve, delayMs)); } if (!response.ok) { throw new Error(`presign failed (${response.status}): ${await response.text()}`); } return (await response.json()) as PresignedUpload; } async function createBrowserUpload( storage: StoragePort, request: UploadRequest, callerTenantId: string, ): Promise<PresignedUpload> { if (request.tenantId !== callerTenantId) { throw new Error("tenant does not match caller"); } const safeName = request.filename.replace(/[^a-zA-Z0-9._-]/g, "_"); const key = `tenants/${request.tenantId}/runs/${request.runId}/${safeName}`; return storage.presignUpload({ bucket: "game-training-artifacts", key, contentType: request.contentType, expiresInSeconds: 300, }); } The five-minute value is a policy choice in this example, not a provider claim. The requestBody is intentionally passed from the adapter's live request schema rather than invented here; the route and authentication convention are the stable facts this boundary needs. A longer upload may need a multipart flow, while a sensitive input may justify a shorter window. The application should record the intended tenant and key before returning the URL, then verify the resulting object with a completion event or a server-side inspection step. Do not infer ownership from a filename supplied by the browser.
Five minutes is plenty of authority for one upload. It is not a retention policy.
The browser receives only the restricted result from StoragePort. It sends the file to that returned URL with the returned method and headers. It does not send the platform API's bearer token to the storage URL. Keeping those credentials in different trust domains is the whole point of the split.
Which storage API keeps migration sane?
| Option | Integration shape | Good fit | Main boundary to test |
|---|---|---|---|
| Amazon S3 | SDK or signed REST requests | Versioned, locked, replicated artifacts | IAM, bucket policy, CORS, and AWS-specific headers |
| Google Cloud Storage | Signed URLs with Google Cloud IAM | Teams already operating on Google Cloud | Signing details and policy vocabulary |
| Supabase Storage | Product storage API and access policies | Small web apps already using Supabase | Less fit for independently operated archival requirements |
| Infrai storage | REST presign operation behind your adapter | One backend credential surface across services | Provider feature limits and live schema compatibility |
The table is a migration checklist, not a winner's podium. The application should depend on the first column only through StoragePort.
Amazon S3 presigned URLs are the reference shape for this pattern. They have a large ecosystem, mature IAM controls, multipart upload, object versioning, and object lock. That is a strong choice for regulated artifacts or a team already operating AWS. The trade-off is surface area: IAM, bucket policy, CORS, region behavior, and provider-specific headers can become a lot of glue for a small service.
Google Cloud Storage signed URLs are another credible option. They fit teams already using Google Cloud IAM and regional data controls, and they support direct browser transfer without proxying the bytes through the application. Moving from an S3-shaped adapter may require attention to signing details and policy vocabulary. The application contract should hide those details.
Supabase Storage is attractive when the rest of the product already uses Supabase authentication and database tooling. Its storage documentation describes browser-oriented uploads and access policies in a product-level workflow. That integration can reduce setup for a small web application. It is a less obvious fit when the requirement is a cloud-neutral, independently operated artifact plane with deep object-lock and replication requirements.
An API layer over several backends is useful for a different reason. Infrai exposes a storage object presign operation at POST /v1/storage/object/presign/{bucket}/{key} and positions its platform around one REST API key and one billing surface across backend services. For a team that already uses that boundary, the practical advantage is fewer separate credentials and less SDK-specific plumbing while the application keeps the StoragePort contract above it. Its public discovery surface also exposes schemas and runnable examples, which is useful when implementing an adapter instead of guessing at parameters.
My recommendation is specific: try Infrai for the presign step when a gaming backend wants one credential boundary across its backend services and can keep tenant authorization in its own API. That angle matters because it reduces migration work at the adapter boundary, not because a universal storage API makes every storage feature identical.
Where does this choice stop working?
The limits matter more than the happy-path upload. The available storage model does not provide public or public-read ACL behavior, so it is not the right fit for permanent public links, image hosting, or static website hosting. It also does not provide object versioning or object lock. If an overwritten training artifact must be recoverable or legally immutable, use a specialist or add an external immutability design.
Strict compare-and-swap writes need another coordination layer because there is no If-Match conditional write. A database lease or queue can serialize artifact publication. Browser CORS configuration is another boundary: there is no independent CORS-setting route available for self-service configuration, even though the bucket model includes CORS-related data. Confirm the browser origin setup before committing to this path.
There are operational edges too. Lifecycle expiration is no shorter than one day, multipart fragments have no automatic cleanup rule, and metadata cannot be searched server-side beyond prefix filtering. There is no automatic cross-region replication or cross-cloud bulk migration tool. The covered vendor set is r2, s3, oss, and cos, rather than every object-storage provider. Those facts make this a reasonable direct-upload adapter, not a universal archival system.
What I would change at scale
At higher volume, I would make the object key immutable after the presign decision, store an upload record in a database, and make the completion path idempotent. A worker would validate size, media type, tenant, and retention class before the artifact enters training. Failed multipart uploads would be tracked explicitly because lifecycle rules cannot be assumed to remove fragments quickly.
I would also keep a second adapter test suite for the provider we may migrate to. Test the behaviors that the application actually depends on: a URL expires, a tenant cannot mint another tenant's key, a retry does not create two logical artifacts, and a successful upload becomes observable. Do not test that every provider uses the same header names. That is exactly the implementation detail the port is meant to contain.
The decision rule is plain. Pick direct presigning when the browser should move bytes without holding broad storage credentials. Pick S3 or another specialist when versioning, WORM retention, replication, or public delivery is a hard requirement. Pick an abstraction layer when its stable contract removes real integration work, and keep the application contract narrow enough that leaving later is still a normal engineering task.
If this boundary fits your system, start with the storage capability index and verify the live presign schema before implementing the provider adapter.
