Short answer: for a media app that must keep the original receipt for audit, upload the original directly from the browser with a short-lived presigned URL, then let a backend job create thumbnails from the stored object. Keep the upload and thumbnail-ready states separate. For very large files, use multipart transfer; for small files, a single PUT is easier to operate.
That recommendation is about byte movement, not fashion. Sending a large receipt image through a Next.js server adds a second network hop and makes application concurrency part of the throughput limit. Sending it straight to object storage removes that hop, but it also makes CORS, signed-request expiry, retries, and completion tracking your problem. I would measure upload duration, p95 thumbnail delay, retry rate, and orphaned-object count before standardizing the pattern. The reliability model comes first; the URL shape comes second.
The receipt ledger is the system boundary
The first guarantee is auditability: the original must be immutable, addressable, and private after upload. Generate an asset ID on the backend and derive the object key from that ID, such as originals/2026/08/<asset-id>.jpg. A client filename is useful display metadata; it is a poor primary key. Store the original MIME type, byte length, checksum when available, uploader, and creation time in an application record. The database record is the audit index; object listing is only a reconciliation tool.
Start with the record.
Use an unambiguous state machine. pending means the browser has received permission to upload. uploaded means the backend has verified that the object exists and its metadata is acceptable. thumbnailing and ready describe derivatives, not the original. A receipt can be audit-ready while its 320-pixel preview is still queued. That distinction keeps a resize backlog from looking like data loss.
Failure drills for a browser upload pipeline
The useful pre-production exercise is not a happy-path click. Refresh the browser after the bytes arrive but before the completion request. Then kill a thumbnail worker after it writes the derivative but before it marks the job ready. Finally, replay the completion request twice. The backend must reconcile an object with its pending asset, and a queue retry must converge on one deterministic derivative key. If those cases are vague, the application does not yet have an upload design; it has a demo. I would write this as a failure matrix with the asset ID, expected database transition, expected object state, and retry owner in separate columns. For an interrupted multipart transfer, the expected result is an incomplete session that a cleanup job can identify. For an expired signing grant, it is a new grant for the same pending asset, not a second audit record. For a duplicate completion, it is one enqueue operation even if the request arrives twice. For a worker interrupted after the write, it is a safe re-read or overwrite of the same derivative key. This detail matters because the original receipt is the thing an auditor may need months later; a thumbnail is only a derived convenience.
Test from the real browser origin, not only from a server-side HTTP client. Cover a successful small upload, a large multipart upload, an expired signature, a changed content type, a dropped connection during one part, a duplicate completion request, and a worker retry. Assert both object state and database state. A 413 response should be a clear contract for an object that is too large, rather than allowing a partial upload to enter the processing queue.
This is the part people skip. Measure upload duration, p95 thumbnail delay, retry rate, queue age, decode time, and orphaned-object count. A single average hides the large-file tail that matters to a media workflow.
How can a browser upload image reach a backend that creates thumbnails?
The browser should request permission from the backend, upload with the exact method and headers covered by the signature, and report completion. The backend should validate the caller before issuing the URL and should never put its storage credential in browser code. A signed URL is delegated access, not an access policy for every object in a bucket.
Use a single upload when the object is comfortably below the service and network limits and a retry can afford to repeat the whole transfer. Use multipart upload when repeating a large transfer is expensive. The client creates an upload session, uploads numbered parts, records each successful part, and asks the backend to complete the session. If the tab closes, the application needs a cleanup job for unfinished sessions; a database row alone does not remove remote parts.
Here is the small part I keep in the Next.js boundary. The storage adapter stays generic, which makes the application testable without choosing a vendor in every route handler.
type UploadGrant = { assetId: string; objectKey: string; uploadUrl: string; expiresAt: string; }; export async function createUploadGrant(input: { filename: string; contentType: string; size: number; }): Promise<UploadGrant> { if (!input.contentType.startsWith("image/")) { throw new Error("Only image receipts are accepted"); } if (input.size <= 0 || input.size > 200 * 1024 * 1024) { throw new Error("Receipt size is outside the accepted range"); } const assetId = crypto.randomUUID(); const extension = input.filename.split(".").pop()?.toLowerCase() || "bin"; const objectKey = `originals/${new Date().toISOString().slice(0, 7)}/${assetId}.${extension}`; return storage.createPresignedUpload({ objectKey, contentType: input.contentType, contentLength: input.size, expiresInSeconds: 600, }); } That size limit is an application decision, not a universal rule. A receipt archive with larger scans should choose a limit from observed object sizes and the browser's failure behavior.
The completion callback is not proof by itself. The backend should look up the expected asset, verify object existence, compare the recorded content type and size with the grant, and only then enqueue thumbnail work. Make completion idempotent. A browser retry and a queue retry should both produce one logical original and one deterministic derivative key.
Derivative isolation and cache policy
Thumbnail generation should read the private original, decode it in a bounded worker, resize to explicitly named variants, and write each result under a separate key such as thumbs/<asset-id>/320.webp. Do not replace the original with a resized version. If a worker sees the job twice, its output should be safe to overwrite or should be guarded by a job lease in the database.
This is where throughput gets misread. A fast upload does not mean a fast user experience if the image worker waits behind an unbounded queue. Track the upload path and processing path separately. Record bytes transferred, queue age, decode time, resize time, write time, and the number of attempts. A large receipt that arrives in seconds but waits minutes for a thumbnail has two different operational problems, and they need two different fixes.
The final choice is a reliability budget
Originals and derivatives have different cache and retention rules. Keep originals private and serve them through an authenticated download path or a short-lived signed read. Thumbnails can be public only if the product's privacy model allows it. Otherwise, sign reads for both and make the URL lifetime match the viewer's task.
Cache-Control is the right HTTP vocabulary for expressing freshness, but it is not an audit policy. For immutable derivative keys, a long freshness window can reduce repeated reads; for metadata or an object whose key may be reused, use a shorter policy. The browser and intermediary caches will follow the response headers, so test the actual response rather than relying on a framework default.
Keep the audit record independent from object listing. The record should point to the original key, checksum, byte length, and processing events. A listing is useful for reconciliation, but it does not tell you which receipt a file belongs to. Run a periodic comparison in both directions: database records without objects, and objects without records.
There is a cost trade-off here. Storage pricing is only one input; request fees, egress, replication, failed multipart parts, and worker CPU can dominate a thumbnail pipeline. I would model those terms with the expected receipt size distribution and retention period. Do not select an architecture from a headline per-gigabyte number.
The catch is operational ownership. Direct browser upload is not suitable when the client cannot reach the storage endpoint, when a strict privacy boundary requires every byte to pass through a controlled gateway, or when the storage service cannot express the needed signed constraints. In those cases, proxy through a backend or a dedicated upload service and accept the extra bandwidth. Stick with a simple single-upload flow when files are small and the team cannot yet operate multipart cleanup and reconciliation.
Measure first. Then choose the shortest path that preserves the original.
References
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control
- https://www.backblaze.com/cloud-storage/pricing
Further reading
- MDN, Cache-Control response header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control
- Backblaze Cloud Storage pricing: https://www.backblaze.com/cloud-storage/pricing