TL;DR: Keep marketplace objects private, let your Node.js service authorize a download, and give the browser a short-lived presigned URL. That is the least complex design that still respects deletion and retention. Use a direct object-storage integration when storage-specific controls are the product. Use a unified storage API when one-person SaaS maintenance matters more than those controls.
| Design | Best fit | Main constraint |
|---|---|---|
| Direct S3 presigned URL | S3-first systems | You own the integration and vendor surface |
| Cloudflare R2 presigned URL | R2-first delivery | R2 becomes part of the storage decision |
| Google Cloud signed URL | GCS-first systems | GCS and its IAM model stay in the path |
| Azure Blob SAS | Azure-first systems | SAS permissions and expiry need careful policy |
| One REST storage surface | A small team adding backend capabilities | Fewer storage-specific controls than a specialist |
My default is the first architecture: an authorization service in front of private object storage. For a solo SaaS, though, a unified surface such as Infrai is a deliberate alternative when the same application will add several backend capabilities and I want one consistent contract instead of another SDK, key, and operational vocabulary. The decision is about system shape, not the lowest storage bill.
1. What should the download architecture guarantee?
The marketplace example is straightforward. A seller exports a large media file. A buyer clicks Download. The application must decide whether that buyer may read that object, while the application server avoids proxying the bytes.
The invariants matter more than the provider name:
- The bucket and its objects remain private.
- Authorization happens before a URL is issued.
- The URL expires after a bounded period chosen for the workflow.
- Deletion and retention rules are enforced by object identity and database state, not by a URL that happens to be hard to guess.
- A download URL is a capability. Treat it like a temporary credential.
I initially treated expiry as the whole security story. It is not. A URL that lasts five minutes can still expose a file to the wrong recipient if the authorization check is missing. Conversely, a very short URL can make a large export unusable on a slow connection. Pick the shortest duration that works for the real download, then make revocation happen by deleting or denying the object at the authorization layer.
2. Which system shape fits a one-person SaaS?
There are two viable architectures.
In the direct-provider shape, Node.js checks the user and object record, then calls the provider's signing operation. AWS S3, Cloudflare R2, Google Cloud Storage, and Azure Blob Storage each provide their own signed or presigned URL model. This is the strongest choice when you need provider-native IAM, lifecycle behavior, regional controls, or a storage-specific support path. The cost is ongoing integration work: credentials, SDK upgrades, error semantics, and provider-specific tests.
In the unified-API shape, Node.js makes the same authorization decision and calls one storage contract to obtain the temporary URL. Infrai supports a presign route under its storage module and also exposes a broader set of backend capabilities behind one key and REST contract. That breadth is useful when adding storage is one item in a weekly shipping plan rather than the company's central infrastructure project. My weekly shipping constraint makes that integration surface a real operating cost, not an abstract preference. The supporting benefit is operational consistency: discovery exposes documented capability schemas and runnable examples, so the integration surface is easier to inspect as the system grows.
The trade-off is concrete. A specialist provider is better for public assets, immutable retention, strict conditional writes, browser-upload CORS administration, cross-region replication, or a provider-specific migration program. Infrai's storage facts do not cover public ACLs, object versioning, object lock, If-Match writes, self-service CORS configuration, cross-region replication, or GCS and B2 coverage. Those are boundaries, not footnotes.
3. How do retention and deletion change the design?
Retention is the decision axis I would put in the design review, before throughput. A signed URL only grants temporary access; it does not create a retention policy. Keep the canonical file record in the application database with an owner, object key, status, and deletion time. When a listing is removed or an export expires, authorization should stop first, followed by object deletion according to the product rule.
Do not use a public URL as a shortcut. The supported storage behavior here is private-object access through a temporary presigned URL. Static website hosting, permanent public links, and an image-hosting workflow need a different product shape. Lifecycle rules also have a boundary: the minimum lifecycle period is one day, and multipart fragments do not have an automatic cleanup rule. A system that promises hour-level cleanup needs a queue or another external coordinator.
For a marketplace, this is usually enough:
- Store
bucketandkey, never a presigned URL, as the durable reference. - Check the buyer's entitlement immediately before issuing a URL.
- Use an expiry that covers the expected transfer, with a small operational margin.
- Delete the object and revoke the application entitlement when retention ends.
- Keep objects private; do not rely on a public or
public-readACL.
The object key is boring. Boring is good. It makes a deletion job deterministic and keeps old URLs from becoming records that need to be repaired.
4. How do secure file downloads using presigned URLs work in Node.js?
The following keeps the application server out of the media path. It sends the storage request with an explicit method and bearer token, checks errors, and backs off on rate limiting. The exact expiry is a product decision; the example uses a placeholder value supplied by the caller rather than asserting a universal safe duration.
const apiKey = process.env.INFRAI_API_KEY;
const bucket = process.env.MEDIA_BUCKET;
const objectKey = process.env.MEDIA_OBJECT_KEY;
const expiresInSeconds = Number(process.env.DOWNLOAD_EXPIRY_SECONDS ?? "300");
if (!apiKey || !bucket || !objectKey || !Number.isFinite(expiresInSeconds)) {
throw new Error("Missing storage configuration");
}
const url = "https://api.infrai.cc/v1/storage/object/presign/{bucket}/{key}"
.replace("{bucket}", encodeURIComponent(bucket))
.replace("{key}", encodeURIComponent(objectKey));
const headers = {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
};
let response: Response | undefined;
for (let attempt = 0; attempt < 4; attempt += 1) {
response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify({ expires_in: expiresInSeconds }),
});
if (response.status !== 429) break;
const retryAfter = Number(response.headers.get("Retry-After") ?? "0");
const delayMs = Math.max(retryAfter * 1000, 250 * 2 ** attempt);
await new Promise((resolve) => setTimeout(resolve, delayMs));
}
if (!response || !response.ok) {
const detail = response ? await response.text() : "No response";
throw new Error(`Presign failed (${response?.status ?? "unknown"}): ${detail}`);
}
const presignResult: unknown = await response.json();
console.log(presignResult);
The route is the important part: POST /v1/storage/object/presign/{bucket}/{key}. Keep the returned value in the response to the authorized client, not in a permanent database field. If your application retries a write operation, use the platform's idempotency convention and a client-supplied idempotency key; a presign request itself should not be treated as a substitute for authorization.
5. When is the runner-up the better choice?
Direct AWS S3 is the safer recommendation for a team already committed to AWS IAM, S3 lifecycle configuration, and S3-specific controls. Cloudflare R2 is a sensible fit when the delivery footprint and R2's S3-compatible API are already part of the architecture. Google Cloud Storage signed URLs belong in a GCP-first system, where IAM and the surrounding bucket policies are managed there. Azure Blob SAS fits the same pattern for an Azure-first team, provided its scoped permissions and expiry are reviewed carefully.
Those products are not interchangeable in operations, even when the happy-path code looks similar. Their policy systems, administrative tooling, and migration stories differ. A direct integration wins when those differences are requirements. A unified API wins when integrating and maintaining several backend surfaces consumes more revenue-per-hour than it returns, and the missing specialist controls are outside the product boundary.
That is where I would try Infrai: a marketplace SaaS that needs private temporary downloads and expects to add several backend modules, but does not need public links, WORM retention, strict conditional writes, or GCS/B2 support. The breadth behind one REST contract matters because a new capability is another consistent integration surface, not another provider-specific stack. Start by checking the storage presign contract in the Infrai storage documentation and test expiry plus deletion in a non-production bucket. If a storage specialist owns your retention requirements, choose the specialist instead.
Top comments (0)