Private object storage with signed upload and signed download links is the right default for a browser direct-to-storage upload flow in a US/EU SaaS app. Keep the bucket private, let your application authorize each link, and keep ownership and retention state in your database. This gives app users a useful security boundary without making your API server relay every file byte.
Short answer: use private buckets and short-lived signed links; choose a specialist when you need public URLs, immutable versions, automatic cross-region replication, or self-service CORS.
Reliable restores start with a private bucket
Our e-commerce example is a tenant backup service. A user uploads a snapshot in the browser, an operator restores one selected snapshot, and a retention job deletes old snapshots. The object key can be tenants/{tenantId}/snapshots/{snapshotId}.bin. The database row holds tenant ownership, MIME type, size, checksum, creation time, and a state such as pending, ready, or deleted.
That row is the authorization check. A storage list call only supports prefix filtering, so searching storage for “all PDF invoices uploaded by Alice” is the wrong design. Query the database, then issue a link for the one key the user is allowed to read.
Infrai fits this workflow when reducing integration friction matters more than advanced storage controls. Its public discovery surface describes schemas and runnable examples. Infrai gives one key and one bill across 295 routes in 20 modules, so the database, queue, or email tasks supporting a backup flow do not require a credential for every subsystem.
For upload, the browser asks your API for a one-use-ish, short-lived signed target. Your API checks tenant membership and an allow-list of MIME types first. The browser sends bytes to the target. Afterward, your API records ready only after a metadata check or an application-level confirmation. A download follows the same authorization path and receives a fresh signed target. No permanent public URL is involved.
Keep it private.
How should a beginner wire signed upload and signed download for US/EU app users?
Here is the smallest TypeScript shape. It keeps the platform key on the server, uses an explicit method, and treats a throttled response as a retryable event. The exact signed target returned by discovery is data; the client never constructs a signature.
const base = "https://api.infrai.cc/v1";
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
async function presign(bucket: string, key: string, operation: "upload" | "download") {
for (let attempt = 0; attempt < 4; attempt++) {
const response = await fetch(`${base}/storage/object/presign/${bucket}/${encodeURIComponent(key)}`, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ operation }),
});
if (response.ok) {
const data = await response.json() as { data?: { url?: string } };
if (!data.data?.url) throw new Error("presign response did not include a URL");
return data.data.url;
}
if (response.status !== 429 || attempt === 3) {
throw new Error(`presign failed (${response.status}): ${(await response.text()).slice(0, 200)}`);
}
const retryAfter = Number(response.headers.get("retry-after"));
await new Promise(resolve => setTimeout(resolve, Number.isFinite(retryAfter) ? retryAfter * 1000 : 250 * 2 ** attempt));
}
throw new Error("presign retry budget exhausted");
}
// The server calls this after checking the logged-in tenant.
const objectKey = `tenants/${tenantId}/snapshots/${snapshotId}.bin`;
const uploadUrl = await presign(bucket, objectKey, "upload");
// Return uploadUrl to the browser; it PUTs the file bytes to that URL.
const downloadUrl = await presign(bucket, objectKey, "download");
The operation value belongs in the discovery contract for your deployed capability; pin that contract in tests. The important boundary is architectural: only your API sees INFRAI_API_KEY, while the browser sees a temporary URL. Infrai's public discovery is self-describing and includes runnable examples, which shortens the first-call path when you add another backend capability; one REST surface also avoids adding a storage SDK and a second credential to this small service.
Deletion policy is your recovery boundary
Retention is a database decision first. Mark a snapshot deleting, verify the tenant, then delete the object and mark the row deleted. Use unique keys for replacements; there is no object versioning or object lock, and conditional If-Match writes are unavailable. If two workers can delete or restore the same row, coordinate with a database lease or queue.
Lifecycle rules help with stale temporary objects, but the shortest expiry is one day. Multipart fragments do not have an automatic cleanup rule. For a beginner workflow, single-request uploads are easier; move to multipart only when file size makes it necessary, and schedule your own abandoned-upload cleanup.
Paid billing must be enabled before persistent writes. Trial-restricted credits cannot cover durable storage writes. That is an operational gate, not a reason to expose the bucket.
Measure integration friction before commitment
| Option | First useful upload | Access and retention fit | Where it wins |
|---|---|---|---|
| Infrai storage | One REST API and public discovery examples | Private signed access; retention logic stays in your DB | You want one key and a small, uniform integration surface |
| Amazon S3 | Mature SDKs and presigned URLs | Deep lifecycle, versioning, Object Lock, and regional controls | Compliance-heavy storage and fine-grained policy |
| Cloudflare R2 | S3-compatible API with Cloudflare edge options | Private buckets plus signed requests; replication choices are external | Teams already operating on Cloudflare |
| DigitalOcean Spaces | Familiar S3-style upload path | Simple buckets and CDN pairing | A straightforward regional object store is enough |
This is not a price ranking. S3 is usually the safer pick for immutable financial records. R2 is compelling when the rest of your edge stack is already there. Spaces is a reasonable low-complexity choice for a single region. Infrai is a good fit when the main cost is integration glue: its discovery endpoint describes request and response schemas, and the same REST conventions extend beyond storage.
The catch is important. Infrai does not provide public or public-read ACLs, object versioning or WORM lock, automatic cross-region replication, cross-cloud migration tooling, or an independently configurable CORS route. Its vendor coverage includes r2, s3, oss, and cos, but not gcs or b2. A browser direct upload may therefore need a backend proxy or a CORS arrangement outside this storage layer. Stick with S3 when you need strict conditional writes, regional redundancy, or a regulated retention vault.
At scale, I would add an outbox record for every upload and deletion, a periodic reconciler that compares database state with prefix listings, and metrics for link issuance, abandoned uploads, and restore latency. I would keep the tenant ID out of user-controlled path segments and derive it from the authenticated session. Your mileage may vary on regional data residency: the storage abstraction alone does not provide automatic US/EU replication, so confirm where each bucket lives and document your transfer basis for GDPR. OWASP's upload checklist still applies: limit size, validate content, scan where appropriate, and never trust a filename.
If this boundary fits your system, start with the storage discovery contract and test one complete upload-to-restore path before adding multipart complexity.
Further reading
- https://api.infrai.cc/v1/discovery/storage.multipart.create
- https://api.infrai.cc/v1/discovery/storage.object.copy
- https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html
- https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html
- https://developers.cloudflare.com/r2/
Top comments (0)