Use a backend-issued, single-object upload capability when a browser must send fintech product images without routing every byte through the application. Keep the bucket private, derive the tenant prefix on the server, allow only the exact browser origin and headers, then confirm the stored object before starting thumbnail work. That is the least complex option that preserves direct transfer and a meaningful tenant boundary.
TL;DR: CORS does not grant storage permission, and a presigned URL does not make a private bucket public. A direct upload fails when the browser's preflight is not allowed, when the signed request differs from the request actually sent, or when temporary authority is mistaken for validation. Treat the URL as a narrow capability. Observe its issue, transfer, confirmation, and resize stages separately.
| Pattern | Pick it when | Tenant boundary | Main operational cost |
|---|---|---|---|
| Application proxy | Files are small or content must be inspected before storage | Application authenticates and streams every write | Application bandwidth and backpressure |
| Presigned direct upload | Browsers send known objects at meaningful volume | Server fixes the object key and signed constraints | Two control-plane calls plus browser CORS |
| Dedicated upload gateway | Policy, scanning, or resumability needs one owned edge | Gateway authenticates and enforces upload policy | Another data-plane service to deploy and observe |
The table is the decision. The rest is how to keep the middle row honest.
Why can direct browser thumbnail uploads to private object storage fail?
There are three independent gates. Picture them in order: browser policy, storage authorization, application acceptance. A green light at one gate says nothing about the next.
First, the browser may send an OPTIONS preflight because a cross-origin PUT with the intended headers is not a CORS-safelisted request. The storage origin must answer with an allowed origin, method, and header set that matches the request. CORS is enforced by the browser; it is not a replacement for authentication or authorization. A command-line client can therefore succeed while the same request fails in a browser. That discrepancy is diagnostic, not mysterious.
Second, signature verification covers a particular request. Changing a signed header, object key, method, or expiration context can invalidate it. Even an unsigned header can trigger a preflight if the CORS policy does not allow it. Avoid adding headers “for completeness” after signing. The browser must send what the signer intended.
Third, successful transfer is not business acceptance. A signed write can constrain where and how an object is uploaded, but the application still needs to decide whether that object belongs to the authenticated tenant, meets image policy, and is eligible for thumbnail generation. The upload response is an input to verification, not proof that the workflow is complete.
Do not solve a preflight error by making the bucket public. That changes the data boundary and does not repair a mismatched signed request.
Pick the control point that matches the risk
An application proxy is a sound choice when every byte must pass through synchronous inspection or when upload traffic is modest enough that another hop is acceptable. Authentication, rate limits, parsing, and storage happen in one place. The trade-off is plain: image bytes consume application connections, memory or temporary disk, and outbound capacity. Backpressure becomes part of the API design.
A presigned direct upload separates control from data. The application authenticates the user and grants a short-lived capability for one server-chosen key; the browser sends bytes to storage. This is a strong fit for product-image intake because the API can remain the authority for tenant placement without becoming the file pipe. It does require disciplined completion handling. Never accept a browser-supplied bucket name or raw object key.
A dedicated gateway earns its keep when upload policy grows into a subsystem: resumable sessions, malware scanning, format normalization, quota enforcement, or protocol translation. It centralizes enforcement and produces consistent telemetry, but it also owns availability for the data path. Choose it for those requirements, not because CORS configuration felt awkward.
For large originals, multipart upload changes the lifecycle. Parts can be uploaded independently and retried, but an initiated upload must eventually be completed or aborted. Storage providers can retain uploaded parts until that happens. Track stale sessions and clean them up deliberately. Thumbnail-sized files rarely justify that state machine; high-resolution source images sometimes do.
Implement one narrow upload capability
Start with an authenticated request that contains business data, not storage coordinates. In this example, the client names a product and declares the media type. The server already knows the tenant from the verified session.
type ImageType = "image/jpeg" | "image/png" | "image/webp"; type UploadRequest = { productId: string; contentType: ImageType; byteLength: number; }; type UploadCapability = { uploadId: string; method: "PUT"; url: string; headers: { "content-type": ImageType }; expiresAt: string; }; interface ObjectSigner { signPut(input: { key: string; contentType: ImageType; expiresInSeconds: number; }): Promise<{ url: string; expiresAt: Date }>; } function objectKey(tenantId: string, productId: string, uploadId: string): string { // All segments are server-derived or validated opaque identifiers. return `tenants/${tenantId}/products/${productId}/originals/${uploadId}`; } async function issueUpload( tenantId: string, input: UploadRequest, signer: ObjectSigner, ): Promise<UploadCapability> { if (input.byteLength < 1 || input.byteLength > 15_000_000) { throw new Error("image_size_rejected"); } const uploadId = crypto.randomUUID(); const signed = await signer.signPut({ key: objectKey(tenantId, input.productId, uploadId), contentType: input.contentType, expiresInSeconds: 300, }); return { uploadId, method: "PUT", url: signed.url, headers: { "content-type": input.contentType }, expiresAt: signed.expiresAt.toISOString(), }; } The 15_000_000-byte product rule and 300-second capability lifetime are example application choices, not storage guarantees. Set both from your threat model and expected file sizes. The important mechanism is that the tenant ID never arrives as authority from the browser, and the response gives the client the exact header contract.
The browser upload should stay boring.
async function uploadImage(file: File, grant: UploadCapability): Promise<void> { if (file.type !== grant.headers["content-type"]) { throw new Error("selected_file_type_changed"); } const response = await fetch(grant.url, { method: grant.method, headers: grant.headers, body: file, }); if (!response.ok) { throw new Error(`upload_failed_${response.status}`); } } Configure storage CORS narrowly: the production web origin, PUT, the headers the signer permits, and only response headers the browser genuinely needs. Do not use reflected arbitrary origins with credentials. Keep development origins in an environment-specific policy rather than broadening production.
After transfer, have the browser send only the opaque uploadId to a completion endpoint. The server resolves the pending record under the authenticated tenant, checks object metadata and size through the storage API, records an immutable source reference, and queues thumbnail generation. Image decoders should still validate the actual bytes; a Content-Type header is a claim.
The worker writes derivatives to a separate, deterministic namespace such as tenants/{tenant}/products/{product}/derivatives/{recipe}/{sourceVersion}. That makes retries idempotent and prevents one tenant's requested output key from crossing into another tenant's prefix. Export generation then queries accepted database records scoped to the tenant. It should not discover export contents by listing a shared bucket prefix supplied by a client.
Make the boundary visible in telemetry
Logging full presigned URLs leaks bearer-like query credentials into log systems. Record the upload ID, tenant ID, stage, result, content length, and a stable error category instead. Redact query strings at the HTTP client and edge layers.
One lifecycle can be drawn in words:
capability_issued -> browser_transfer -> object_confirmed -> resize_completed -> export_included
Instrument the transitions. A counter for outcomes at each stage exposes where work stops. Histograms for confirmation latency and resize duration show queue or decoder pressure. A gauge for pending uploads is useful only if it is paired with age; 500 fresh uploads and 500 uploads stuck for an hour mean different things.
Use low-cardinality metric labels such as stage, result, media type, and deployment region. Tenant IDs, product IDs, object keys, and upload IDs belong in logs or traces, not metric labels. This keeps the metrics system usable while preserving a path for investigation.
Alert on user-visible symptoms and boundary violations. Examples include a sustained rise in preflight failures at the edge, a high ratio of issued capabilities without confirmation, resize failures above the normal baseline, and any server-side attempt to resolve an upload under a tenant different from its pending record. The last event should be impossible by construction. Measure it anyway.
A crisp diagnostic split helps on call. If preflight fails, inspect origin, method, and requested headers. If storage rejects the PUT, compare the sent request with the signed contract and check expiration. If upload succeeds but no thumbnail appears, follow the upload ID through confirmation and the worker. These are different failure domains, so one generic “upload failed” metric hides the answer.
Test isolation before trusting it
Unit tests should prove key construction ignores client storage paths and rejects invalid identifiers. Integration tests need two tenants. Issue a capability as tenant A, complete it as A, then attempt to complete the same upload ID as tenant B. The second call must reveal no object metadata and create no database relation. Repeat the check for export generation: an export for A contains only A's accepted records, even if object names share product-like values.
Run browser tests against the real CORS policy. Exercise the allowed origin, a disallowed origin, the exact signed headers, an extra header, an expired capability, and a retry. A storage emulator can validate workflow logic, but it may not reproduce browser preflight behavior or a provider's signature implementation. Keep at least one deployed-environment test that uses a non-production bucket and an actual browser engine.
Test the unhappy timing too. Confirmation may race object visibility or be retried after a client timeout. Workers may receive the same job twice. The pending-upload record, source version, and derivative key should make those cases deterministic rather than destructive.
Limits to keep explicit
Presigned uploads delegate a bounded write; they do not scan content, guarantee that declared media types are truthful, or revoke bytes already accepted. Very short expirations can hurt users on slow links, while long expirations enlarge the window in which a leaked capability works. Pick a lifetime from observed transfer distributions, then monitor expiration failures before changing it.
Private storage also does not settle delivery policy. Thumbnail reads may use authenticated application responses, short-lived read capabilities, or a controlled distribution layer. Keep that decision separate from upload CORS, and preserve the same tenant authorization rule.
The final rule is compact: the backend chooses identity and placement; storage moves bytes; confirmation admits the object into the product model. CORS lets the browser participate. Observability proves where the chain held or broke.
Further reading
- MDN, Cross-Origin Resource Sharing: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
- Fetch Standard, CORS protocol: https://fetch.spec.whatwg.org/#http-cors-protocol
- OWASP, Authorization Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html
- AWS S3, Uploading and copying objects using presigned URLs: https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html
- AWS S3, Multipart upload overview: https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html
![Motion Planning and Navigation — Ch.04: Optimization Based Planning [KR]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqyrjjn7tc2h8vbe5rduk.png)
![Motion Planning and Navigation — Ch.05: Local Planners [KR]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0tuhfqde1o6zcyskw7f4.png)
![Motion Planning and Navigation — Ch.07: Multi Robot Navigation [KR]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwj9k0uan25q7slmyqpoo.png)
![Motion Planning and Navigation — Ch.10: Navigation2 Stack [KR]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6asnejhpxvcrd68qhrfg.png)