The constraint that changes this design is large-file throughput. An education platform should keep export bytes off its application workers, issue a short-lived download URL only after authorization, and record the retention decision next to the artifact metadata. That gives a Node.js API a small control-plane job while the storage service handles the long data path.
Short answer: create the export as an immutable object, sign a GET request for a narrow time window, and make retention a policy evaluation rather than a deletion timer scattered through request handlers. The URL is a capability, not proof that the caller remains authorized.
The detail that tends to bite teams is reproducibility. If a course export contains submissions, grading evidence, and generated reports, a later audit must be able to answer which policy selected its expiry and which inputs produced the object. A timestamp alone cannot do that.
What changes when training exports get large?
A small PDF can pass through an API without attracting much attention. A training archive with video, captions, and assessment evidence changes the economics of the request path: buffering it in a web process consumes memory, ties up a connection, and makes retries compete with authentication traffic. The export endpoint should therefore return metadata and a signed URL; the client then downloads the object directly from the storage layer.
Consider a completed course export assembled from a manifest. The manifest names each source object, its generation, and the transformation that produced the final archive. If the worker streams that archive through the API, a learner retry can occupy an application connection while the same bytes are read again from storage. If the worker writes a finalized object and the API signs only that object, retries move to the storage data path. That makes the control plane easier to protect with ordinary request limits, and it gives support a stable export ID to investigate. The trade-off is an extra finalization state: a link must not be issued while the object is still being written. Record the object generation after the write completes, then sign against that generation when the storage system supports it. Without that ordering, a URL can point at a key whose contents change underneath a download, which is exactly the kind of intermittent result that is hard to reproduce.
I keep three identifiers separate: the export ID exposed to the learner, the immutable object key, and the policy version that selected the expiry. That separation prevents a renamed course or a retried job from quietly changing the meaning of an old link. It also gives observability something useful to group by.
The signed request should carry only the permissions needed for this download. A GET scope, an exact object key, a short expiration, and the intended response disposition are enough for the common case. Do not put a bearer token in a query parameter that lives for a day just because the archive took an hour to produce.
Which boundary should the API own?
The API owns identity, authorization, policy selection, and audit records. Storage owns bytes, range responses, checksums where supported, and the high-throughput transfer. A queue or worker owns export assembly. Keeping those responsibilities distinct matters during a retry: the worker can safely resume or replace a temporary object while the API continues to enforce the same learner and tenant rules.
Here is the shape I use for the policy decision. It is deliberately an interface, not a provider SDK call; the important contract is the data recorded with the export.
from dataclasses import dataclass
from datetime import datetime, timedelta
@dataclass(frozen=True)
class RetentionDecision:
policy_version: str
expires_at: datetime
reason: str
def choose_retention(artifact_class: str, completed_at: datetime) -> RetentionDecision:
if artifact_class == "assessment-evidence":
days = 365
reason = "assessment evidence policy"
else:
days = 30
reason = "standard training export policy"
return RetentionDecision(
policy_version="training-retention-2026-01",
expires_at=completed_at + timedelta(days=days),
reason=reason,
)
The production policy needs a versioned configuration and an explicit rule for missing classifications. I prefer failing the export job closed over silently assigning a longer retention period. The exact durations are domain policy, not a property of presigned URLs.
How should a temporary download link behave?
A request for a link first checks the authenticated principal against the export record. Only then does the API ask storage to sign a read request. The API returns the URL, expiration, object size if known, and a stable export ID. It does not return storage credentials.
A useful test matrix includes an expired URL, a URL for a different object key, a revoked export, a user removed from the course, and a download that uses byte ranges. Test the browser path as well. Cross-origin downloads can fail even when the signature is valid if the storage response does not expose the headers that frontend code needs. MDN documents the CORS response-header rules; treat them as part of the delivery contract, not a frontend afterthought.
For large objects, a client may retry a failed range. That makes idempotent object reads valuable, but it does not make the export job idempotent automatically. Give the assembled object a content hash or generation marker, write the metadata only after finalization, and make repeated requests return the same completed export while it remains valid.
What differs across storage implementations?
The design is portable, but the signing and lifecycle primitives are not identical. Amazon S3 supports presigned requests and lifecycle configuration; Google Cloud Storage supports signed URLs and lifecycle management; Azure Blob Storage uses shared access signatures and lifecycle management policies. Their credential models, condition syntax, maximum signing windows, and lifecycle rule details differ, so hide those operations behind a small adapter and test the adapter against each target.
The comparison is a boundary check, not a ranking. A team selecting an implementation should verify four things in current documentation: whether a signed read can be restricted to one object, how expiration is represented, whether lifecycle deletion is evaluated asynchronously, and how range requests and response headers behave. A provider feature named “temporary access” does not answer all four.
| Approach | Access method | Best fit | Boundary to verify |
|---|---|---|---|
| Object-storage SDK | Server-side signing library | An API that already owns storage credentials | SDK defaults can hide signing conditions and response-header behavior |
| Object-storage REST API | Explicit signed request | A small adapter shared by several services | Canonical request construction and clock skew need careful tests |
| Storage gateway | Application-facing download endpoint | Environments requiring a single policy boundary | The gateway can become the throughput bottleneck if it proxies bytes |
Keep the byte path boring.
One rule.
I also keep a provider-neutral audit event: export_link_issued with the export ID, subject ID, policy version, object generation, expiration, and request trace ID. Never log the complete URL. Query-string signatures are credentials for their lifetime, and logs tend to outlive the link.
A controlled rollout for retention changes
Start with one artifact class and a shadow policy that records what it would have selected without deleting anything. Compare the proposed expiry with legal, academic, and support requirements. Once the policy version is approved, apply it to new exports, then migrate existing metadata in batches. Deletion should be a separate worker with a grace period and a reconciliation report.
The useful success measure is not the number of links issued. Watch worker memory, application egress, completed-download rate, range retry rate, authorization denials, and objects past their selected expiry. A sudden increase in signed-link requests may mean a client is refreshing too aggressively; a healthy byte path can still hide a broken policy path.
For a Node.js implementation, the framework details are secondary: stream the export creation pipeline, keep signing in the authenticated API boundary, and pass the resulting URL to the client without proxying the file. The durable decision is the contract between authorization, immutable object metadata, and versioned retention.
Sources
- MDN, “Cross-Origin Resource Sharing (CORS)”: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
- Amazon Web Services, “Sharing objects with presigned URLs”: https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html
- Amazon Web Services, “Managing your storage lifecycle”: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html
- Google Cloud, “Signed URLs”: https://cloud.google.com/storage/docs/access-control/signed-urls
- Google Cloud, “Object Lifecycle Management”: https://cloud.google.com/storage/docs/lifecycle
- Microsoft Learn, “Delegate access with a shared access signature”: https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview
- Microsoft Learn, “Azure Blob Storage lifecycle management policy”: https://learn.microsoft.com/en-us/azure/storage/blobs/lifecycle-management-overview
Top comments (0)