Highlights

Contents

Part III
03

Presigned URLs and direct upload

We move large bytes directly between the client and storage while the application controls permission. Delegated upload access must be narrow enough that a leaked capability cannot change unrelated objects. We will calculate transfer cost, constrain signed requests, bound expiration, and recover interrupted sessions.

CHAPTER ATLAS / FOLLOW THE READING PATHCHAPTER ATLAS / FOLLOW THE READING PATH1Local, block, file,object storage2Buckets, objects andmetadata3Presigned URLs and directupload4Multipart uploads5Checksums and integrity6Replication anddistributed file systems7Lifecycle and retention8Case study: the mediaupload path

#Section 9Why the application should not proxy every video

Heron’s illustrative video is 5,000,000,000 bytes. If the application receives it and forwards it, the application path handles 10,000,000,000 payload bytes across ingress and egress. A small 2,000-byte control exchange is a different workload. Their ratio is 5,000,000 in this simplified byte-count exercise.

At an illustrative direct transfer rate of 10,000,000 bytes per second, upload takes 500 seconds. If the application-proxied bottleneck is 2,000,000 bytes per second, it takes 2,500 seconds. These are assumed link rates, excluding setup, retransmission, storage work, and protocol overhead.

METADATA GOES THROUGH THE APP; THE 5 GB GOES STRAIGHT TO STORAGEMETADATA GOES THROUGH THE APP; THE 5 GB GOES STRAIGHT TO STORAGEclientapplicationDBobject storesmall JSONpresigned PUT: 5 GBat 10,000,000 B/s direct: 500 s; through a 2,000,000 B/s app: 2,500 s
Figure 13.9Direct-upload architecture. The application controls the operation without proxying the complete payload.

The application creates a pending record, reserves an object identity, and returns delegated access. The client then uploads bytes to storage. Completion returns through the application so it can verify that the reserved upload met its constraints. The absence of payload proxying does not remove ownership, validation, or quota checks.

#Section 10Presigned URLs delegate a specific operation

A presigned URL is a request whose authorization parameters are signed by an identity with permission to perform the operation. The holder can use that delegated operation while the signature and underlying authority remain valid. It is a capability and should be handled as a secret during its usable lifetime.

For Heron, reserve a private unique upload key and sign only the required method and resource. Bind supported required headers, checksum, or content constraints when the chosen API permits them. Do not give a client general bucket credentials or a reusable key for overwriting another user’s published clip.

A PRESIGNED REQUEST GRANTS ONE NARROW OPERATION ON A RESERVED OBJECTA PRESIGNED REQUEST GRANTS ONE NARROW OPERATION ON A RESERVED OBJECTuploadersigned requestreserved keywrite methodexpiry / conditionsstorage servicestorage validates the delegated request at its own boundary
Figure 13.10Presigned-operation boundary. Supported constraints depend on the specific operation and signature scheme.

S3 presigned URL documentation explains expiration and authority constraints. Presigned access is not inherently single-use. Repeated use may overwrite or repeat the permitted operation under its actual object rules, so immutable identity and state validation still matter.

#Section 11Expiration follows the underlying credential

Heron requests an illustrative 3,600-second URL lifetime, but the signing temporary credential has only 1,200 seconds remaining. The delegated authorization cannot outlive the required underlying credential. The simplified effective lifetime is the smaller value, 1,200 seconds, subject to other policy restrictions.

A 5,000,000,000-byte transfer at the assumed direct rate takes 500 seconds. Against an illustrative 600-second upload planning budget, that leaves 100 seconds. A URL expiring before the expected retry horizon can cause a partial upload to need fresh delegated access rather than forcing the client to discard all progress.

ASKED FOR 3,600 S, THE URL LIVES 1,200 S; THE UPLOAD NEEDS 500 + 100 MARGINASKED FOR 3,600 S, THE URL LIVES 1,200 S; THE UPLOAD NEEDS 500 + 100 MARGINrequested 3,600 seffective 1,200 stransfer 500 + margin 10006001,2001,8002,4003,0003,600 sthe shorter of the URL and the signing credential wins
Figure 13.11Illustrative planning arithmetic. Request-start, ongoing-transfer, and reissued-request expiration semantics are product-specific.

Do not claim that every ongoing transfer is terminated exactly at its signed expiration. Check when the service validates the request and what happens to a reconnect after expiration. Multipart transfers make this clearer: individual part requests can obtain fresh scoped signatures while preserving the same upload session.

#Section 12Initiate, upload, verify, publish

The client obtains upload access but closes the tab halfway through. The database must not treat initiation as a playable clip. Use a state machine such as pending, uploaded, verified, processing, and published, with failed or expired states where necessary.

Initiation records ownership and expected content constraints. Upload completion confirms storage state under the reserved identity. Verification checks length, checksum type and value, and required inspection. Processing creates derived immutable objects. Publication changes the database pointer only after its required objects and facts are ready.

PENDING → UPLOADED → VERIFIED → PUBLISHED: ONLY THE LAST IS PLAYABLEPENDING → UPLOADED → VERIFIED → PUBLISHED: ONLY THE LAST IS PLAYABLEpendinguploadedverifiedpublishedprocessing into renditions can sit between verified and published
Figure 13.12Simplified publication states. Heron’s processing stage can occur between verification and publication when renditions are required.
THE CLIENT CLAIMS "DONE"; THE APP CHECKS THE OBJECT ITSELFTHE CLIENT CLAIMS "DONE"; THE APP CHECKS THE OBJECT ITSELFclientapplicationc7/source-v1initiatereserved key + signed URLupload bytescomplete?HEAD: length, checksumpublish only from verified storage evidence
Figure 13.13Direct-upload sequence. A completion request is a claim to verify, not proof supplied by the client.

Make each transition idempotent under its upload identity. A duplicate completion call should recover the same state rather than start duplicate conversions or create duplicate metadata. Retain unfinished reservations long enough for recovery, then reclaim them through a safe cleanup rule.