Browser File Uploads and Object Storage Service Choice: Retention Before Presigned URLs
Short answer: for a property-management portal, the cheapest object store is rarely the one with the lowest storage line item. The useful choice is the one that lets the browser upload directly, gives each file a clear r
Short answer: for a property-management portal, the cheapest object store is rarely the one with the lowest storage line item. The useful choice is the one that lets the browser upload directly, gives each file a clear retention decision, and makes deletion observable. That changes the question from price shopping to lifecycle design.
Imagine a maintenance coordinator uploading a 240 MB inspection video from a phone. The browser should send bytes to object storage through a short-lived presigned request. The application should receive metadata, not the video stream. A later cleanup job should be able to answer two questions: why is this object still here, and what evidence says its deletion was attempted?
The before model is browser -> application -> storage. Every byte takes the application path, so request time, memory pressure, and retry behavior become coupled to the upload. The after model is browser -> storage, with the application authorizing a narrow upload and recording the resulting object. The application remains the policy boundary. It just does not carry the payload.
The boundary matters.
How should a browser choose an object storage service for file uploads?
A presigned URL is an upload handoff, not a retention policy. I would create a record before issuing it with a property identifier, an opaque upload identifier, the intended media type, an expiry timestamp, and a retention class such as inspection, lease, or temporary. The object key can include the opaque identifier, but it should not contain a tenant name, street address, or other readable identity.
The retention class is the decision that survives service changes. A temporary object might be deleted after a failed form submission. An inspection object might remain while the related work order is open. A lease attachment might follow a legal or business schedule defined outside this upload endpoint. The exact duration belongs to the organization and its obligations; the implementation should make that duration data, rather than scattering it through controllers. That is a real trade-off: a backend with fewer lifecycle primitives may still work, but the application then owns more cleanup code and more review cases.
The browser can upload successfully while the application record is still pending. That is normal. A confirmation step should verify the object metadata and size against the upload intent, then move the record to accepted. An expired or abandoned intent should move to expired, and its object should enter the deletion queue. Do not treat a client callback as proof of deletion.
How do retention and deletion become observable?
Deletion needs a state machine. queued, requested, confirmed, and needs_review are more useful than a single boolean because object storage and application databases do not commit one transaction together. Keep the intent row and deletion attempt history in the application database. The worker can retry an attempt with a bounded schedule, but it should stop retrying forever and surface a review state.
A compact deletion record might look like this:
type DeletionState =
| "queued"
| "requested"
| "confirmed"
| "needs_review";
type MediaObject = {
uploadId: string;
objectKey: string;
retentionClass: "inspection" | "lease" | "temporary";
deleteAfter: string;
deletionState: DeletionState;
lastDeletionAttemptAt?: string;
};
The useful metrics are small and specific: accepted uploads by retention class, expired intents, deletion age, and objects in needs_review. Log the upload identifier, not the full presigned URL. URLs can contain credentials for a limited operation, so they do not belong in ordinary request logs.
Keep it boring.
Cache behavior belongs in the same conversation. A response's Cache-Control header describes how caches may store and reuse that response; it is not a deletion command. For private property media, define cache behavior deliberately and avoid assuming that removing an object instantly removes every cached representation. The application should also stop issuing fresh download links after the record is no longer authorized.
Is the cheapest service still cheapest after cleanup?
This is where a spreadsheet can mislead. Compare the full path: storage duration, requests, transfer, failed retries, lifecycle features, audit retention, and the engineering work needed to detect orphaned objects. A low storage rate does not compensate for a cleanup design that leaves abandoned videos indefinitely. At the same time, paying for a richer platform does not remove the need for an application-level intent record.
Use a small test corpus before choosing a backend: one 0-byte file, one file near the product limit, a duplicate filename, an interrupted upload, an expired URL, and an object whose database record is deliberately removed. Observe the browser result, the stored metadata, the worker outcome, and the dashboards. This catches assumptions that a happy-path upload never exposes.
There is a boundary here. Direct upload is a poor fit when every byte must be transformed synchronously before storage, or when the application must inspect content before accepting it. In those cases, a staged quarantine flow or an application-side stream may be justified. It costs more moving parts, but it matches the requirement instead of pretending that a presigned handoff solved it.
| Decision | Direct-to-storage fit | Main trade-off |
|---|---|---|
| Large inspection video | Good | Cleanup and confirmation are separate steps |
| Temporary failed-form media | Good | Orphan detection must be explicit |
| Synchronous content transformation | Limited | Add a quarantine or processing stage |
I would also make deletion a deployment invariant. A new upload flow is incomplete until it has an expiry path, a worker metric, an operator-visible review state, and a test for an object that outlives its intent. That is a modest checklist. It prevents a large media archive from becoming an accidental archive.
A practical decision rule
Choose the storage option that supports the required direct-upload protocol and gives the team a clear way to enforce the retention classes. Then measure the operational surface over a week of representative test traffic. The winner is the option whose total lifecycle is understandable: authorization, upload, acceptance, expiry, deletion, and review. A direct-upload service is the wrong choice when the team cannot observe or reconcile those states.
For a property-management team, that clarity matters more than a tiny difference in a storage quote. Media has a purpose and an end date. Encode both before the first byte leaves the browser.
Further reading
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.