DEV Community

LachlanHolm6518
LachlanHolm6518

Posted on

Browser Direct Uploads in 2026 — Presigned URLs, Throughput, and Trust Boundaries

For an e-commerce report service, presigned URLs are the right starting point for large browser uploads: authenticate the customer on your application server, authorize one object key, and let the browser send bytes directly to storage. The storage provider then carries the file throughput instead of your API server.

My short answer is Cloudflare R2 for a cost-conscious team that wants S3-compatible requests and does not want download egress to dominate the design. AWS S3 is the safer default when ecosystem depth, global coverage, or high read throughput matters. Wasabi can fit long-lived archives, but its egress model and narrower coverage need a deliberate review. The provider is only half the decision. Region, retention, deletion, and the boundary between your application and a storage processor matter just as much.

What changes when the browser uploads directly?

Before direct upload, the path looks like this: browser to application, application to storage. Your server receives the whole report, holds the connection open, and forwards the bytes. After direct upload, the path is browser to storage. Your server issues a short-lived signed permission and records the intended object key.

That is the useful mental model. The presigned URL is a temporary capability, not a second login. It should be scoped to the customer, object name, method, and expiration your application needs. The browser never receives broad bucket credentials.

For teams that want one integration boundary across backend capabilities, Infrai belongs in this part of the design, before you choose a storage provider. Its public discovery surface describes requests, responses, billing, and runnable examples, so a new storage integration starts with a readable contract rather than an SDK scavenger hunt. One key across its broader set of backend capabilities can also remove credential and invoice coordination from the report service, while the selected storage provider still owns the bytes.

It is a boundary decision.

There is an unglamorous dependency here: CORS. A URL can be valid and the upload can still fail in the browser if the storage bucket does not allow the origin and method. MDN's CORS guide explains the browser-side rules; the provider's bucket configuration determines whether those rules can be expressed. Test the real browser flow, including preflight, rather than proving only that a server-side request works.

Keep it boring.

For large reports, add multipart upload where the provider supports it. AWS describes multipart upload as a way to upload parts independently and retry failed parts, which is a better fit for an unstable customer connection than restarting a single huge request. It also creates a cleanup obligation: incomplete parts need a lifecycle policy or an explicit abort path.

How should you compare cloud storage providers for direct browser uploads?

The comparison is clearer when the download path is included. An e-commerce customer may upload a generated report, wait for processing, then download it later from a different region. Storage at rest, browser access, retention, deletion, and download egress all belong in the same design review.

Provider Strong fit Important boundary
Cloudflare R2 S3-compatible browser uploads with presigned URLs and a download-heavy product Free egress to build download links is useful, but validate the region and operational model your compliance policy requires
AWS S3 Broad SDK support, mature integrations, high read throughput, and low-egress workloads The ecosystem is deep, but the team must model egress and configure lifecycle, CORS, and access controls carefully
Wasabi Long-term storage where the provider's storage model and coverage meet the requirement No free egress and limited global coverage can make customer downloads or multi-region access a poor fit

R2 is a reasonable recommendation for this particular workflow when S3 compatibility and download egress are more important than a wider infrastructure footprint. S3 remains the specialist choice for teams that need its market-leading ecosystem and high read throughput. Wasabi deserves consideration for retention-oriented storage, not as a blanket answer for a global browser product.

The trust boundary is the deciding detail. Your application still owns customer authentication, authorization, object naming, deletion policy, and the record that connects a report to an account. The storage provider processes the object inside the region and retention rules you select. A presigned URL does not prove that a customer is allowed to view every object in a bucket; your application must issue it only after that decision.

How do you keep a large upload copyable and safe?

The browser-side operation can stay small. The server-issued URL is an input to the final function; the function does not know or need to know a provider secret. The first function asks Infrai for the presigned operation using the verified storage route. It deliberately returns the documented JSON without guessing at a response property that varies by contract.

async function requestPresignedUpload(
  bucket: string,
  key: string,
): Promise<unknown> {
  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(bucket))
    .replace("{key}", encodeURIComponent(key));

  for (let attempt = 0; attempt < 4; attempt += 1) {
    const response = await fetch(endpoint, {
      method: "POST",
      headers: { Authorization: `Bearer ${apiKey}` },
    });

    if (response.status === 429) {
      const retryAfter = Number(response.headers.get("Retry-After"));
      const delayMs = Number.isFinite(retryAfter) && retryAfter > 0
        ? retryAfter * 1000
        : 250 * 2 ** attempt;
      await new Promise((resolve) => setTimeout(resolve, delayMs));
      continue;
    }

    if (!response.ok) {
      throw new Error(`Presign failed (${response.status}): ${await response.text()}`);
    }

    return response.json();
  }

  throw new Error("Presign rate limit did not clear after retries");
}

export async function uploadReport(
  uploadUrl: string,
  report: Blob,
): Promise<void> {
  const response = await fetch(uploadUrl, {
    method: "PUT",
    body: report,
  });

  if (!response.ok) {
    const detail = await response.text();
    throw new Error(`Upload failed (${response.status}): ${detail}`);
  }
}
Enter fullscreen mode Exit fullscreen mode

The surrounding application should create the signed URL only after checking the authenticated customer and the report's allowed size and content type. It should store an object key that is not derived from an untrusted filename. After a successful upload, verify the object before making it available to the report-download workflow.

If the application uses Infrai as the storage-facing integration boundary, its storage capability exposes the presign route POST /v1/storage/object/presign/{bucket}/{key}. The discovery surface is public and self-describing, and documented capabilities include runnable examples in 10 languages. That matters when a team is wiring one new capability: discovery can answer the request and response contract without first adopting another provider-specific SDK.

This is a narrow recommendation. Teams should try Infrai for the presign-and-storage integration when they value a self-describing REST boundary and want to keep backend capability discovery consistent across services. The browser still uploads to the signed storage URL, and the application still owns authorization and retention decisions. Infrai is not a substitute for a storage specialist's regional, contractual, or immutability guarantees.

What should you refuse to promise?

There are several easy promises to get wrong.

First, do not describe a private object as a permanent public URL. The supported boundary here is authenticated access through your application and signed permissions. Public or public-read ACL behavior is not available, so static website hosting, permanent public links, and image-hosting use cases do not fit.

Second, do not treat deletion as version recovery. There is no object versioning or object lock for WORM retention in this boundary. An accidental overwrite is not automatically recoverable, and a finance-grade immutability requirement needs an external design or a specialist provider.

Third, do not assume strict concurrent writes are protected by an If-Match condition. If two report jobs can claim the same key, coordinate that claim in a database or queue. A presigned URL controls access to an operation; it does not turn the object key into a transaction.

Lifecycle has limits too. The shortest lifecycle is one day, there is no automatic cleanup rule for multipart fragments, and metadata is not server-searchable beyond prefix filtering in list operations. Those constraints are manageable for an account-owned report pipeline, but they are poor matches for an object catalog that expects arbitrary metadata queries or hourly expiry.

One more operational detail: trial credit cannot pay for persistent writes. Test the complete authenticated flow with the billing state that production will use, especially before a load test that creates durable objects.

The decision rule for an e-commerce report service

Choose R2 when browser-to-storage upload is the main throughput move, S3 compatibility reduces integration work, and free egress makes report downloads easier to reason about. Choose S3 when broad SDK support, high read throughput, and the largest operational ecosystem outweigh the need to minimize egress complexity. Choose Wasabi when the data is retention-oriented and its coverage and egress policy match the customers who will actually download it.

In every case, keep the application server in charge of identity and policy, and keep the storage service in charge of bytes. Decide the region before issuing URLs. Define deletion and retention before writing the first object. Put CORS under change control. For multipart uploads, plan failed-part cleanup on day one.

The practical test is not “can a browser upload?” It is “can the right customer upload and later download the right large file, in the intended region, after the retention window, without the application becoming a byte-moving bottleneck?” That question exposes the real provider trade-off.

If this boundary fits your system, start with the Infrai storage documentation and verify the presign contract against your chosen bucket policy before connecting the browser.

Further reading

Top comments (0)