Short answer: authorize an upload intent in the API, let the browser send the report straight to object storage, validate the resulting object from a trusted callback, and make retention state part of the report record rather than an implicit bucket policy.

For customer-facing logistics reports, the hard part isn't moving bytes. It's proving that the right tenant supplied the expected file, publishing it only after validation, and deleting every copy when its retention window closes. Those four controls should be separate because they fail at different times and need different evidence.

Keep the first version boring.

How should a Node Express API validate direct browser object storage uploads?

The useful pattern has three trust boundaries. The browser can ask for permission and upload bytes, but it can't declare the upload valid. Object storage can confirm that an object exists, but it doesn't know which customer may read a logistics report or how long that report should remain. The application API owns those decisions and records them in its database.

The flow is short: an authenticated staff user asks the API for an upload intent; the API binds a random object key to a tenant, report, expected media type, size ceiling, and deletion time; the browser uploads to a narrowly scoped signed URL; a storage event reaches a private callback; and a worker compares trusted object metadata with the intent before changing the report from pending to ready. Customer download authorization remains a separate request-time check.

Don't use the object key as authorization. A key is a locator.

HTTP method semantics help keep the boundaries legible. The intent creation request is POST because it creates server-side state. A successful callback that has no response representation can return 204. Replaying the same storage event should produce the same database outcome, while a callback for an object whose stored constraints don't match the intent should leave the report unpublished. RFC 9110 defines these method and status semantics; the application still has to enforce tenant ownership and state transitions.

Why does the upload intent need its own API?

This TypeScript sketch keeps storage signing behind an interface. The route names are application-owned examples, not a vendor contract. A production implementation would also persist the authenticated actor and an audit timestamp, but those details are omitted here so the trust boundary stays visible.

import express from "express"; import { randomUUID } from "node:crypto"; type UploadIntent = { id: string; tenantId: string; reportId: string; objectKey: string; contentType: "application/pdf" | "text/csv"; maxBytes: number; deleteAfter: string; state: "pending" | "ready" | "rejected" | "deleted"; }; type StorageSigner = { signUpload(input: { key: string; contentType: string; maxBytes: number; expiresInSeconds: number; }): Promise<{ url: string; headers: Record<string, string> }>; }; const app = express(); app.use(express.json()); const intents = new Map<string, UploadIntent>(); const storageSigner: StorageSigner = createStorageSigner(); app.post("/upload-intents", requireStaffSession, async (req, res) => { const tenantId = req.auth.tenantId; const reportId = String(req.body.reportId ?? ""); const contentType = req.body.contentType; const maxBytes = 25 * 1024 * 1024; if (!reportId || !["application/pdf", "text/csv"].includes(contentType)) { return res.status(400).json({ code: "invalid_upload_request" }); } const id = randomUUID(); const objectKey = `tenants/${tenantId}/reports/${reportId}/${id}`; const deleteAfter = calculateDeletionTime(req.body.retentionClass); const intent: UploadIntent = { id, tenantId, reportId, objectKey, contentType, maxBytes, deleteAfter, state: "pending", }; await saveIntent(intent); intents.set(id, intent); const upload = await storageSigner.signUpload({ key: objectKey, contentType, maxBytes, expiresInSeconds: 600, }); return res.status(201).json({ intentId: id, uploadUrl: upload.url, requiredHeaders: upload.headers, expiresInSeconds: 600, }); }); 

The browser receives only what it needs for one upload. It doesn't receive storage credentials, a tenant-wide prefix, or permission to choose the final key. The 600-second lifetime and 25 MiB ceiling are example policy values, not universal recommendations; large generated archives may need multipart upload and a different expiry calculation. What matters is that both values are decided on the trusted side and stored with the intent.

The browser can then upload without routing the report through the application process:

type UploadGrant = { intentId: string; uploadUrl: string; requiredHeaders: Record<string, string>; }; export async function uploadReport(file: File, grant: UploadGrant): Promise<void> { const response = await fetch(grant.uploadUrl, { method: "PUT", headers: grant.requiredHeaders, body: file, }); if (!response.ok) { throw new Error(`upload_failed:${response.status}`); } } 

No success screen should make the report customer-visible yet. A browser receiving 200 or 204 from storage proves that its request completed; it doesn't prove that the application matched the object to an active intent, checked the stored size and media type, or accepted the retention class. Show an honest processing state until the trusted validation path finishes.

Test expiry, cancellation, and late-arrival races

Retention starts as a product rule, then becomes a data model rule. For example, a customer contract might require a delivery exception report to remain available until a fixed date, while an internal preview should disappear much sooner. The API should translate that class into an absolute deleteAfter value when it creates the intent. Saving only a label such as standard is risky because changing the label's policy later can silently change the meaning of existing records.

Use one record to answer four different questions:

Field Decision it supports Trusted writer
tenantId Who may discover or download the report? Application API
objectKey Which stored object belongs to this report? Application API
state Is the report publishable or already deleted? Validator and deletion worker
deleteAfter When does deletion become due? Application policy

Deletion should also be a state transition, not a nightly best-effort command with no ledger. A worker selects due ready or rejected records, requests object deletion, verifies the object is absent, and then records deleted with a completion timestamp. If derived previews, search indexes, or cached downloads exist, include them in the same deletion job and retain per-artifact evidence. The report row can remain as a tombstone for audit purposes while customer-visible content and object locators are removed according to the applicable policy.

There is a race worth designing on paper: an upload URL may still be valid when a user cancels the report. Mark the intent rejected first, then delete any present object. If a late callback arrives, the state machine must refuse to move rejected back to ready and should schedule deletion again. This is why a single uploaded: true flag isn't enough.

Be careful with compliance labels. FedRAMP is a US government risk and authorization program, not a generic synonym for secure storage. A team handling federal workloads needs to evaluate the complete authorized system boundary and its own obligations; an upload diagram alone can't establish compliance. I'm not sure which retention evidence a particular agency contract will demand, because that comes from the contract and system authorization package, so the schema should preserve timestamps and actor records without pretending they settle the policy question.

Make webhook callback delivery reliable under replay

A callback crosses another boundary even if it comes from infrastructure you operate. Verify its authenticity using the storage system's documented mechanism, reject stale messages according to that mechanism, parse a strict schema, and deduplicate on a stable event identifier. Then load the intent by the exact object key and compare metadata obtained through a trusted storage read. Don't accept tenantId, size, or media type merely because the callback body contains them.

type StorageEvent = { eventId: string; objectKey: string; }; app.post("/internal/storage-events", rawBody(), async (req, res) => { if (!verifyStorageEvent(req)) { return res.status(401).json({ code: "invalid_callback_signature" }); } const event = parseStorageEvent(req.body) as StorageEvent; if (await hasProcessedEvent(event.eventId)) { return res.status(204).end(); } const intent = await findIntentByObjectKey(event.objectKey); if (!intent || intent.state !== "pending") { await recordProcessedEvent(event.eventId); return res.status(204).end(); } const object = await readObjectMetadata(intent.objectKey); const matchesIntent = object.bytes <= intent.maxBytes && object.contentType === intent.contentType; await runInTransaction(async () => { await setIntentState(intent.id, matchesIntent ? "ready" : "rejected"); await recordProcessedEvent(event.eventId); if (!matchesIntent) await enqueueDeletion(intent.objectKey); }); return res.status(204).end(); }); 

Exact signature fields and delivery guarantees vary by storage implementation, so copy those details from the implementation's primary documentation rather than inventing a universal header. The stable application behavior is what matters: duplicates are harmless, unknown keys never publish a report, and validation failure leads to a non-public state plus deletion.

Polling is a valid alternative when authenticated callbacks aren't available or when operating another inbound endpoint is a poor fit. The catch is added storage reads and slower publication. A queue between callback receipt and metadata validation is better when validation is expensive or bursty; a small deployment can validate inline if it keeps the callback fast and preserves idempotency. Stick with server-proxied uploads when files must be inspected before any bytes reach object storage, when the storage target can't enforce the signed constraints you require, or when browser-to-storage networking is forbidden by the deployment boundary.

Rollout needs lifecycle evidence, not upload counts

The useful dashboard starts with states and age, not raw request volume. Track pending intents older than the signing window, ready reports approaching deletion, rejected objects awaiting removal, callback deduplication counts, and deletion jobs that haven't yet produced verification evidence. Alert on age thresholds tied to your policy. A backlog of ten minutes may be harmless for a monthly report and unacceptable for a customer waiting on a dispatch manifest; the service-level target should come from the job, not from a generic storage metric.

Deployment tests should exercise state transitions against an isolated bucket or a compatible local implementation. Create an intent for tenant A, upload the allowed type, replay the same callback twice, and confirm there is one ready report. Then try an oversized object, a key with no intent, a cancelled intent followed by a late event, and a customer from tenant B requesting the finished report. Finally, advance the clock beyond deleteAfter and verify both content removal and the audit record. These aren't exotic edge cases. They are the contract.

Cost deserves a line item, not the lead argument. Direct uploads remove application bandwidth and process time from the byte path, but metadata reads, callback processing, retention scans, replicated objects, and deletion verification still consume resources. Estimate those operations per report and set a budget alert around the complete lifecycle. For a solo builder, fewer moving pieces can be worth more than shaving a small amount from storage requests.

Before shipping, read the intent route as an attacker, trace every way a report becomes ready, and trace every artifact created from the original object. Confirm that customer downloads re-check tenant membership rather than trusting an old URL. Confirm that cancellation and scheduled expiry converge on the same deletion worker. Confirm that logs contain intent and event identifiers but no signed URLs. Then run the deletion test in deployment, because a retention promise without observable deletion is only a comment in a schema.

The resulting choice is conditional: direct browser upload is a strong fit when the API can issue narrow grants and validate asynchronously, but it is not suitable when policy requires synchronous inspection before storage or forbids direct client access to the storage boundary. Retention and deletion decide the architecture. The upload request is the easy part.

References