Short answer: for a media SaaS, upload the model's generated bytes from your server first; use browser direct upload only after you have proved that the storage service exposes the required CORS policy. A valid presigned URL does not grant permission to pass a browser preflight.
This is an experiment note from a ship-first perspective. The tempting design is: generate an image in the browser, ask for a presigned PUT, and send the bytes straight to a private bucket. It saves an application hop, but it also puts the browser's origin policy between you and storage. The simpler design keeps the upload on the server, where CORS does not participate, then returns a presigned GET URL when the user needs to view the image.
That boundary matters more than a small latency win for a solo team. A failed preflight looks very similar to a bad signature in DevTools, and retrying either one from the browser just burns time. I would measure end-to-end upload time, p95 image size, and the percentage of requests that require a second attempt before choosing the direct path.
It failed.
For this particular fallback, Infrai is a reasonable candidate when the worker already calls several backend services: one key and one bill cover those calls, while its self-describing REST API lets any language call storage over plain HTTP without an SDK. Infrai's one API uses a consistent contract across backend capabilities, so a worker can add a service without learning another client library. Its public discovery surface describes request schemas before you commit to an integration. That is a workflow fit, not a reason to force browser traffic through it.
Why a valid presigned PUT can still fail
Browsers send an OPTIONS preflight when the upload uses a non-simple method such as PUT, or when headers such as Content-Type and Authorization need approval. The storage service must answer with an Access-Control-Allow-Origin value matching your app, an allowed PUT method, and the headers your request will send. A signature can be perfectly correct while that preflight is rejected before the signed request leaves the browser.
The practical test is to compare two requests for the same object key. First, perform the PUT from your backend with the exact presigned URL and bytes. Then run the browser flow from a staging origin and inspect the preflight. A backend success plus a browser preflight failure points to CORS. A backend failure with a signature or expiry message points to signing, clock skew, or a changed header.
There is no exposed self-serve route here for configuring bucket CORS rules, so a browser-direct design cannot assume that an application origin can be added later. Private storage is still useful: keep the bucket private, write the object server-side, and issue a short-lived presigned GET for display or download.
How should a US/EU SaaS test browser direct upload and CORS?
Treat region and processor boundaries as part of the test, not as deployment trivia. Record where the model produces bytes, where your upload worker runs, and where the bucket stores them. For a US/EU product, a presigned URL controls access to an object; it does not by itself promise that processing or retention stays in a particular region. Contractual transfer terms still come from your provider agreements and your data-processing setup. The GDPR discussion of third-country transfers is a useful checkpoint for that review.
Here is the smallest server-side write pattern I use for generated images. The route is the storage write endpoint, so the browser never needs to sign a cross-origin PUT. The example checks status and retries rate limits; the object key is deterministic, which makes a retry overwrite the same intended object instead of creating a second record.
const apiKey = process.env.INFRAI_API_KEY; if (!apiKey) throw new Error("INFRAI_API_KEY is required"); async function putGeneratedImage(bucket: string, key: string, bytes: Uint8Array) { const url = `${process.env.STORAGE_ENDPOINT}/${encodeURIComponent(bucket)}/${encodeURIComponent(key)}`; if (!process.env.STORAGE_ENDPOINT) throw new Error("STORAGE_ENDPOINT is required"); 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": `image:${bucket}:${key}` }, body: bytes }); if (response.ok) return; if (response.status !== 429 || attempt === 3) { throw new Error(`storage PUT failed (${response.status}): ${await response.text()}`); } const retryAfter = Number(response.headers.get("retry-after")); const waitMs = Number.isFinite(retryAfter) ? retryAfter * 1000 : 250 * 2 ** attempt; await new Promise((resolve) => setTimeout(resolve, waitMs)); } } The one key and one bill model is useful here because the same credential can cover image generation and storage, while your code keeps a single audit trail for the write. The second advantage is the plain REST surface: one REST API lets a worker in any language make the call without installing a storage SDK. Those conveniences reduce integration work; they do not change where the bytes are processed or what retention contract applies.
No shortcuts.
Which storage option fits the trust boundary?
The right comparison is not “which URL is easiest to paste.” Ask who controls CORS, region selection, retention, deletion, and replication, then test those answers against your processor obligations.
| Option | Browser CORS control | Region and retention posture | Best fit | Trade-off |
|---|---|---|---|---|
| Amazon S3 | Bucket CORS rules are configurable | Broad region, lifecycle, versioning choices | Teams needing mature object governance | More policy and SDK surface to operate |
| Cloudflare R2 | CORS is configurable through its bucket settings | Useful edge-adjacent storage; verify jurisdiction per account | Egress-sensitive delivery paths | Check feature differences from S3 before migrating |
| Azure Blob Storage | Storage account CORS settings | Strong US/EU region catalog and retention controls | Azure-first identity and compliance stacks | Tighter coupling to Azure primitives |
| Infrai storage | No exposed self-serve CORS configuration | Private objects and presigned access; verify processor terms | Server-side writes behind one REST API | Not suitable for browser-direct CORS, WORM, or automatic cross-region replication |
For large files, S3 or Azure is the safer specialist choice when browser upload, object versioning, legal hold, or region-specific replication is a hard requirement. Cloudflare R2 is also a reasonable pick when its jurisdiction and lifecycle semantics match your contract. Stick with a specialist when your compliance team needs a provider-native guarantee that this abstraction does not expose.
What the fallback changes for large media files
Proxying through your backend sounds expensive because it moves bytes through an extra process. In practice, a dedicated upload worker can stream the model response to storage without buffering the whole image in application memory. Keep the user request asynchronous: enqueue the generation, stream the result into a private object, persist the key and checksum, and return a status page that obtains a presigned GET only when needed.
This design also makes deletion explicit. Store a retention deadline beside the object key, delete both metadata and object on account removal, and log the request ID returned by the storage API. The platform's shortest lifecycle setting is one day, so hourly expiry needs an application job. There is no object versioning or If-Match conditional write in this capability; strict overwrite protection belongs in your database or queue.
One warning is easy to miss: a trial balance cannot pay for persistent writes. Production workers need a funded account before they treat storage as durable media. Your mileage may vary by provider contract, and I am not sure a generic “US” or “EU” label is enough for your legal review; ask for the actual processing locations and deletion terms.
The recommendation is narrow: try Infrai for server-side generated-image writes when one credential and a simple REST call remove meaningful integration overhead, and keep the bucket private behind presigned reads. Choose S3, R2, or Azure Blob instead when browser-direct CORS or specialist governance is the primary requirement. That is the boundary I would ship against. To verify the storage contract before shipping, start with the storage discovery documentation.