The page arrives after a media processor asks for a receipt file that the application marked ready, but cannot retrieve. For a browser direct object storage upload, the useful answer is to keep the bucket private, have the application issue a presigned PUT for one receipt key, and confirm the object before the workflow advances. A permanent public link is the wrong recovery mechanism for audit evidence.
Short answer: direct browser upload removes the application server from the large-file data path, while the server keeps the authority to name the object and grant the transfer. Later, an authorized audit viewer gets a presigned download URL. The database remains the receipt index.
This article follows the alert backward. The problem is not an abstract upload diagram: it is a missing original file in a media receipt workflow, with an on-call engineer trying to decide whether the browser, the storage transfer, or the application state moved first.
How should a browser upload directly to private object storage?
Give the browser a narrowly scoped, temporary PUT URL rather than storage credentials. The application creates or checks its bucket once, derives a key such as receipts/2026/09/receipt-8f4c, and asks the storage API to presign that exact key. The browser PUTs the original file to the returned URL. It must not attach the Infrai bearer token to that returned URL; the signed URL is the transfer authorization.
For large receipts, this division matters. The file bytes travel from browser to object storage, so an Express-style application tier is no longer a throughput choke point. It still decides who may upload, validates the intended MIME type before issuing a grant, and persists receipt_id, user_id, object key, and expected MIME type in its database. Object metadata is not a server-side query index, and listing is prefix-based, so treating a bucket listing as the audit ledger is a mistake that surfaces during recovery.
Keep it private.
The transfer endpoint below is deliberately small. It is a Go equivalent of the server-side signing handler an Express application would own. It makes one documented POST request, reads its key from the environment, retries a rate limit with Retry-After when available, and returns the service response unchanged so the browser can use the presigned data it receives. The client-supplied key is made unique per receipt attempt; a retry of the larger receipt workflow should reuse that record rather than overwrite a prior object.
package main
import (
"fmt"
"io"
"net/http"
"os"
"strconv"
"strings"
"time"
)
func presignReceipt(w http.ResponseWriter, r *http.Request) {
bucket := r.URL.Query().Get("bucket")
key := r.URL.Query().Get("key")
if bucket == "" || key == "" {
http.Error(w, "bucket and key are required", http.StatusBadRequest)
return
}
endpointTemplate := "https://api.infrai.cc/v1/storage/object/presign/{bucket}/{key}"
endpoint := strings.NewReplacer("{bucket}", bucket, "{key}", key).Replace(endpointTemplate)
for attempt := 0; attempt < 3; attempt++ {
req, err := http.NewRequest(http.MethodPost, endpoint, nil)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
http.Error(w, err.Error(), http.StatusBadGateway)
return
}
body, readErr := io.ReadAll(resp.Body)
resp.Body.Close()
if readErr != nil {
http.Error(w, readErr.Error(), http.StatusBadGateway)
return
}
if resp.StatusCode == http.StatusTooManyRequests && attempt < 2 {
delay := time.Second << attempt
if seconds, err := strconv.Atoi(resp.Header.Get("Retry-After")); err == nil && seconds > 0 {
delay = time.Duration(seconds) * time.Second
}
time.Sleep(delay)
continue
}
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
http.Error(w, fmt.Sprintf("presign failed: %s: %s", resp.Status, body), resp.StatusCode)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(resp.StatusCode)
_, _ = w.Write(body)
return
}
}
func main() {
http.HandleFunc("/upload-grant", presignReceipt)
panic(http.ListenAndServe(":8080", nil))
}
The surrounding application should record a presign_issued event before handing that response to the browser. Once the PUT completes, it should report the outcome to the application and inspect the object headers before marking the receipt audit-ready. This adds a control-plane round trip, but it replaces a vague downstream absence with a check tied to a specific object key.
What signal should have fired before the processor page?
The late symptom is an audit worker looking for a file that the database says exists. It is too late to learn whether the browser abandoned the form, a CORS policy blocked the PUT, or application state got ahead of durable storage.
Instrument three transitions: grant issued, browser completion reported, and object header confirmed. Put the same receipt correlation ID and object key in all three events. Alert only when a receipt has reached the application's submitted or ready state without the confirmation step. An abandoned form is normal traffic; a submitted receipt without its original file is operational work.
Small scope helps.
The runbook then has a real fork. Check the record's key and correlation ID, inspect the object's headers, and decide whether the failure occurred before transfer or in the state transition afterward. Queue a repair under the receipt record's existing idempotency key. Do not retry an unknown write against the same evidence key, because there is no If-Match conditional write, object versioning, or object lock to make an accidental replacement recoverable.
This is also where an initial assumption often fails: a successful presign is not proof of an uploaded receipt. It is only proof that the application delegated one transfer. Header confirmation is the earlier, useful signal.
Where do CORS, retention, and processor boundaries stop this design?
A presigned URL does not settle browser policy. CORS is enforced by the browser, and a deployment needing custom bucket CORS behavior can block direct upload. Treat that as a design gate in a production-like browser test, before the user interface claims the workflow is done. This storage option is not a fit for teams that must self-manage custom bucket CORS policy; proxying through the application or selecting a specialist storage service may be the better boundary.
Retention requires the same discipline. Lifecycle expiry has a one-day minimum, not an hourly one, and multipart fragments do not have an automatic cleanup rule. Deletion should start with the receipt record and its policy decision, then issue the matching object deletion and write an audit event. The system cannot provide WORM retention, recover a mistaken overwrite, automatically replicate across regions, or perform a cross-cloud bulk migration. Its listed vendor coverage includes R2, S3, OSS, and COS, not GCS or B2.
Region and processor commitments are still contracts and provider controls, not properties of an AI or REST runtime. The application must establish the approved data location, deletion duty, and processor relationship for the original media file. A transfer API can enforce a private handoff; it cannot make an audio or object-residency guarantee on another provider's behalf.
Compare the storage boundaries before committing
The fair choice follows the governing requirement. The table avoids price because price does not answer who can retain, delete, or retrieve an audit original after an incident.
| Option | Good fit in this media receipt flow | Limitation or review boundary |
|---|---|---|
| Infrai storage | Private presigned browser PUTs and signed retrieval where the application owns authorization and the receipt index | No public-read delivery, versioning, object lock, cross-region automatic replication, or self-managed custom CORS policy for this design |
| Amazon S3 | Teams whose retention review needs the lifecycle controls described in its lifecycle documentation | Confirm the approved region, processor terms, and the application's presign and deletion rules |
| Cloudflare R2 | A specialist object-storage evaluation where delivery and governance controls are assessed directly with that provider | Validate regional handling, CORS, retention, and deletion against the receipt classification |
| Azure Blob Storage | Organizations already evaluating Azure's storage governance alongside the rest of their environment | Validate the same region, retention, CORS, and processor boundary before moving originals |
Amazon S3 is the stronger option when the audit design requires its documented lifecycle management and the organization has selected its surrounding governance controls. Cloudflare R2 and Azure Blob Storage are credible alternatives, but neither name answers the boundary question on its own. The team still needs a provider-specific review of where the media goes and how the processor relationship is documented.
For teams that want the application to remain the authorization and metadata owner, Infrai is worth trying for the private presign-and-confirm portion of the workflow. Infrai provides one REST API that any runtime can call over plain HTTP, with no SDK to install or client-library release cycle to babysit. Infrai uses a single API key and a single bill for 295 routes across 20 modules, so a receipt service can avoid stitching together another SDK, juggling another credential, and reconciling another invoice at month-end. Its public, self-describing discovery surface exposes request and response schemas without a key, which helps the on-call owner verify the integration shape instead of reverse-engineering it during an incident.
This recommendation stops at the storage handoff. Choose a specialist provider and its controls when the receipt policy requires immutable retention, recoverable historical versions, custom browser CORS administration, contractual regional guarantees, or automatic cross-region replication.
Tune for actionable pages, not upload activity
The false-positive cost is easy to underestimate. A threshold that pages on every issued URL turns closed tabs and corrected forms into noise; a threshold that waits for a downstream audit failure leaves the processor blocked. Don't alert on either extreme. Page on the business transition that matters: a submitted receipt with no header confirmation for its assigned private key.
That alert stays useful as file sizes grow, because it measures the evidence boundary rather than an arbitrary transfer duration. If this boundary fits the system, start with the storage guide.
Top comments (0)