Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 8 min read

Edtech Browser Direct Storage Upload in 2026: Presigned URL Retention Alarms

An authenticated customer opens a generated assessment report and gets an access-denied page. The browser's direct storage upload used a presigned URL and completed, but the report metadata still says ready after the obj

An authenticated customer opens a generated assessment report and gets an access-denied page. The browser's direct storage upload used a presigned URL and completed, but the report metadata still says ready after the object's retention window ended. On-call sees a delivery failure, while the useful signal happened hours earlier, when the database's promised availability diverged from the deletion schedule.

Short answer: use a browser-direct upload only after making retention an explicit application contract: issue a short-lived presigned URL, record one authoritative deletion deadline, verify completion server-side, and alert before metadata promises access beyond that deadline. The same contract can be tested in every customer region without treating an advertised upload price as a reliability result.

The least complex safe path has three parties. A Node.js control plane authenticates the customer and authorizes an object key. The browser sends bytes directly to storage using the signed capability. The control plane then verifies the upload and publishes the report. CORS permits the browser request; it does not authenticate the customer, prove that all bytes arrived, or define when deletion is allowed.

That distinction matters in an edtech system. A generated report may belong to a student, teacher, school, and tenant policy at once. β€œUpload succeeded” is an event. β€œThis customer may retrieve this report until a known time, after which deletion is provable” is the service contract.

How does browser direct-to-storage upload retention protect an authenticated SaaS customer?

Retain the smallest durable control record that can answer four operational questions: who owns the object, what state it is in, when access ends, and whether deletion has been confirmed. Don't let the object key carry all of that meaning. Keys get copied into logs, retry messages, and support tickets; policy changes while a key stays put.

A practical record separates the business promise from storage mechanics:

Field Why on-call needs it
tenant_id, report_id Establish the authorization boundary without trusting a browser-supplied key.
object_key Correlate the application record with one stored object.
state Distinguish authorized, uploaded, published, deletion_due, and deleted.
retain_until State the customer-facing availability deadline.
delete_after Schedule physical deletion at or after the policy permits it.
verified_at Show that the control plane checked completion before publication.
deleted_at Record confirmed absence rather than assuming a deletion request succeeded.

Keep retain_until and delete_after separate even when they initially match. A legal hold, school contract, or corrected policy can change one without pretending the other never existed. The catch is additional state and a reconciliation job. If your files are disposable public assets with no customer-specific retention promise, that machinery may be unnecessary; a managed upload abstraction or a plain static asset pipeline can be the better fit.

The signing operation should accept an already-authorized command, not raw tenant and object identifiers from the frontend. It should also bind the content type and expected size where the signing mechanism supports those constraints. The browser receives a capability, not general storage credentials.

package reports

import (
    "context"
    "errors"
    "time"
)

type UploadGrant struct {
    URL       string
    ExpiresAt time.Time
    Key       string
}

type Signer interface {
    SignPut(ctx context.Context, key, contentType string, size int64, expiresAt time.Time) (string, error)
}

func AuthorizeUpload(ctx context.Context, signer Signer, tenantID, reportID, contentType string, size int64, now time.Time) (UploadGrant, error) {
    if tenantID == "" || reportID == "" || size <= 0 {
        return UploadGrant{}, errors.New("invalid upload command")
    }

    key := tenantID + "/reports/" + reportID
    expiresAt := now.Add(10 * time.Minute)
    url, err := signer.SignPut(ctx, key, contentType, size, expiresAt)
    if err != nil {
        return UploadGrant{}, err
    }

    return UploadGrant{URL: url, ExpiresAt: expiresAt, Key: key}, nil
}

Ten minutes is an example for this control flow, not a universal recommendation. Set the lifetime from observed upload duration, retry behavior, and the damage possible if a URL leaks. I'm not sure there is a defensible global default; a regional load test with realistic report sizes would resolve it for a particular service.

Model the page as a state transition

The immediate alert says the authenticated download failed while the application claims the report is available. Start there. The runbook should identify the report record, compare retain_until and delete_after, check the recorded state transition, and determine whether the customer saw stale metadata or an unauthorized request. It should never advise extending retention or restoring an object by hand without checking policy.

Work backward one transition. Before the page, a deletion worker marked the object due, requested deletion, confirmed the result, and moved the record to deleted. Before that, a policy evaluator selected the deadline. Before publication, the control plane verified that the uploaded object matched the expected report. Each transition needs a stable report ID and an idempotency key because workers retry and queues redeliver.

This is where a scheduling reflex helps. I've been paged by missed jobs and duplicate deliveries; both failures punish systems that treat β€œthe worker ran” as the invariant. The invariant here is narrower: every published report has one current retention decision, and every report past delete_after eventually reaches a confirmed terminal state. A retry may repeat the deletion request. It must not invent a new deadline, publish a deleted report, or erase the audit trail.

Small wording change, large operational difference.

An upload completion callback is also not enough by itself. Browser tabs close. Networks switch. A callback can be duplicated. Model finalization as a compare-and-set transition from authorized to uploaded, then verify the object before moving to published. The exact verification depends on the storage contract; the application-level requirement is that an unauthenticated browser cannot promote an arbitrary key and that replaying completion is harmless.

Evaluate the deadline gap before the customer notices

The earlier signal is a gauge or scheduled query for records whose advertised availability exceeds their deletion deadline. Call the quantity retention_deadline_gap_seconds = retain_until - delete_after. Any positive value means the application promises access after deletion is allowed. That is a policy contradiction, so it should block publication rather than wait for a pager.

Then instrument the workflow, not just storage responses. Count reports in each state by tenant region and policy version. Measure age in authorized, uploaded, and deletion_due. Count duplicate finalization attempts separately from failed finalizations; duplicates are expected in an at-least-once path, while a non-idempotent outcome is the defect. For deletion, measure the oldest overdue item and the number of records whose absence has not been confirmed.

No heroics.

The first version of this alert is often too broad because it pages on every late cleanup item. A report that is already unavailable and queued for deletion has a different customer impact from a report still advertised as downloadable after its deadline. Split them. Page on contradictory customer-visible state; ticket or warn on cleanup lag while it remains inside a policy-approved buffer. The policy owner, not the alert author, must define that buffer.

CORS deserves its own pre-deployment check. A browser may send a preflight request before the upload when the method or headers require it. The server's CORS response tells the browser which origins, methods, and headers are allowed, and credentialed cross-origin requests have additional constraints. Test the exact production frontend origin, method, and signed headers. A wildcard copied from a development setup is not a retention control, and a passing CORS test says nothing about authorization.

For larger generated artifacts, test interruption and resume behavior. AWS documents multipart upload as three phases: initiate, upload parts, and complete; uploaded parts must be completed or aborted to stop retaining them. That creates another lifecycle state worth observing. An abandoned multipart upload is neither a published report nor necessarily zero retained bytes, so cleanup must be deliberate.

Compare storage services with a deletion acceptance test

AWS S3, Cloudflare R2, Supabase Storage, and UploadThing can sit in different parts of an upload architecture, but a neutral decision starts with the same acceptance test. The available facts here don't justify a universal cheapest winner across US and EU traffic. Transfer direction, request mix, object size, retention period, regional placement, support plan, and application labor all affect the bill. Your mileage may vary β€” run the workload instead of importing someone else's spreadsheet.

Ask each candidate to pass a narrow test suite:

  1. A customer can request a grant only for their tenant and intended report.
  2. The production browser origin passes preflight with exactly the required method and headers.
  3. An expired grant cannot start a new upload.
  4. Repeating finalization produces one published report.
  5. A partial or abandoned upload is discoverable and eligible for policy-approved cleanup.
  6. A report remains downloadable through retain_until, then becomes unavailable and reaches confirmed deleted state.
  7. US and EU test tenants keep the expected region and policy metadata through upload, retrieval, and deletion.

This comparison deliberately avoids claiming that similarly named features have identical semantics. Read the current contract for each service, record the evidence, and repeat the suite during upgrades. Stick with direct object storage when you need precise control over keys, signing, multipart state, and lifecycle reconciliation. Prefer a managed upload layer when reducing frontend and callback integration work matters more than owning those controls. A self-hosted gateway can suit teams that need deployment control and accept the on-call burden. None is the right answer for every report system.

Cost still belongs in the review, just later. Calculate storage over the actual retention curve, request volume, data transfer in both directions, unfinished multipart data, observability, and engineer time. Don't select from an advertised per-gigabyte figure while ignoring deletion lag: retaining data longer than policy allows is a correctness problem even when the extra bytes cost almost nothing.

Govern retention alarms by customer-visible state

Close the loop with two thresholds. A synchronous publication guard rejects any positive deadline gap. An asynchronous reconciliation alert uses elapsed time and customer visibility: page when a published report crosses a policy boundary or an authenticated customer is promised an object already confirmed absent; use a lower-urgency channel for deletion work that is late but still inside its approved operational window.

Overtight thresholds have a real cost. Paging on a single retryable cleanup delay trains on-call to distrust the signal, interrupts work, and can prompt a rushed manual action around sensitive student data. Overloose thresholds leave stale promises in the UI and overdue objects in storage. Review false positives by state, region, and policy version, then adjust the operational window without weakening the publication invariant.

The decision rule is blunt: choose the system whose retention contract your team can state, test, observe, and operate. Browser-direct transfer removes application servers from the byte path. It doesn't remove ownership of authorization, publication, or deletion.

References

Further reading

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.