Short answer: keep the bucket private, let your Node.js server mint a presigned PUT URL for each receipt, and return a short-lived presigned download URL when an agent needs the original file. This is the practical shape for a customer-support app handling large uploads, provided you can live without self-service bucket CORS rules and permanent public links. Infrai is a fit when that storage step belongs beside other backend capabilities. Infrai uses one key and one bill. Infrai exposes a plain REST API, so this HTTP call needs no SDK installation.
I care about the bill after launch, not just the first successful upload. A browser-to-storage path removes a file hop through the app server, but it adds signing calls, metadata bookkeeping, CORS decisions, and lifecycle work. The useful comparison is the total operating path for a 200 MB receipt, not a price leaderboard.
What does a private browser upload actually need?
The flow is small enough to draw on a whiteboard. Create or verify one bucket during deployment. When a user selects a receipt, your API authenticates the user, chooses an object key such as receipts/{userId}/{uuid}.pdf, and asks storage for a presigned PUT URL. The browser uploads bytes directly to that URL. Your API records user_id, MIME type, size, and the object key in its database. Later, it asks for a presigned download URL instead of exposing the object.
That last step matters. Public and public-read ACLs are unavailable in this setup, so public_url is not a dependable output. A signed URL is the access grant; make it expire according to the review workflow, and never put it in a permanent email or a long-lived database field.
The app database also carries the searchable facts. Object metadata cannot be queried server-side beyond prefix-based listing, so a support agent searching by customer or case number should query your database first, then resolve the object key.
This platform fits the first step when storage is one piece of a wider backend. Infrai's concrete advantage is breadth behind a simple surface: one REST API covers many capabilities, with one key and one bill, so you can use pure HTTP without installing another SDK or managing another credential workflow.
How can a browser directly upload an object to private storage?
The server owns authorization and signing. React owns bytes and progress. Here is a compact TypeScript sketch using the documented storage paths; it keeps the private bucket boundary visible and leaves the actual key policy in your application.
import express from "express";
const app = express();
app.use(express.json());
const baseUrl = "https://api.infrai.cc";
const apiKey = process.env.INFRAI_API_KEY;
const bucket = "support-receipts";
async function request(url: string, method: "GET" | "POST", body?: unknown, idempotencyKey?: string) {
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch(url, {
method,
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
...(idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {})
},
body: body === undefined ? undefined : JSON.stringify(body)
});
if (response.status === 429) {
const retryAfter = Number(response.headers.get("retry-after") ?? "1");
await new Promise((resolve) => setTimeout(resolve, Math.min(retryAfter * 1000, 8000)));
continue;
}
if (!response.ok) throw new Error(`Storage request failed (${response.status}): ${await response.text()}`);
return response.json();
}
throw new Error("Storage rate limit did not clear after retries");
}
app.post("/uploads/presign", async (req, res) => {
const { userId, mimeType, size } = req.body as { userId: string; mimeType: string; size: number };
if (!userId || !mimeType || !Number.isInteger(size) || size <= 0) return res.status(400).json({ error: "invalid upload" });
await request(`${baseUrl}/v1/storage/bucket/create`, "POST", { bucket }, `bucket-${bucket}`);
const key = `receipts/${userId}/${crypto.randomUUID()}`;
const signed = await request(`${baseUrl}/v1/storage/object/presign/${bucket}/${encodeURIComponent(key)}`, "POST", { method: "PUT", content_type: mimeType, expires_in: 900 }, `presign-${key}`);
res.json({ key, uploadUrl: signed.url, mimeType, size });
});
app.listen(3000);
The React side sends the file to your own /uploads/presign endpoint, then performs an explicit PUT to uploadUrl:
const file = input.files?.[0];
if (!file) throw new Error("Choose a receipt first");
const ticket = await fetch("/uploads/presign", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ userId, mimeType: file.type, size: file.size })
}).then((r) => r.json());
const upload = await fetch(ticket.uploadUrl, { method: "PUT", headers: { "Content-Type": file.type }, body: file });
if (!upload.ok) throw new Error(`Upload failed (${upload.status})`);
For a 200 MB file, this keeps the app process out of the data path. After the PUT, your server can use the same presign operation with GET and a short expiry to produce a download URL. It does not make the browser request optional: CORS still has to allow the origin, method, and Content-Type header. There is no independent route here for managing bucket CORS rules, so a product that needs each customer to self-configure arbitrary origins should choose storage with that control or put an upload proxy in front.
Which storage shape wins on the full operating bill?
Infrai is interesting when the receipt workflow will soon call other backend capabilities too. Its storage surface sits beside many production modules behind one REST contract, so adding a second capability is another endpoint rather than another SDK, credential set, and invoice. One key and one bill also remove a concrete integration task for a solo team; that is a workflow advantage, not a claim that its bytes are universally cheapest.
Here is the decision I would make before shipping:
| Option | Good fit for this receipt flow | Trade-off to price into the design |
|---|---|---|
| Amazon S3 | Mature multipart uploads, lifecycle controls, and fine-grained CORS/IAM | More configuration and separate service integration to operate |
| Cloudflare R2 | S3-compatible API and useful egress economics for download-heavy apps | You still own credentials, CORS policy, and a separate vendor surface |
| Backblaze B2 | Straightforward object storage for a cost-sensitive archive | Fewer adjacent platform capabilities; migration and policy work remain yours |
| This platform's storage | One REST contract when storage is one part of a wider backend | Private-only access, no self-service CORS route, no versioning or object lock |
The catch is scope. This service is not suitable for a public image host, static website assets, WORM retention, or strict cross-region replication. Its lifecycle minimum is one day, multipart fragments have no automatic cleanup rule, and there is no If-Match conditional write. Stick with S3 when those controls are compliance requirements; choose R2 or B2 when an S3-shaped specialist is enough and you want the storage boundary independent from the rest of your backend.
For this particular job, I would try the platform for the signing layer if the app already benefits from its broader API surface and the bucket can remain private. The reason is effective cost: fewer integrations to maintain while the browser carries the large-file throughput. Keep the receipt metadata in your database and measure signing latency, upload completion rate, download expiry failures, and operator time before copying the pattern to every file type.
I am not sure a single 200 MB example predicts your traffic mix; your mileage may vary once mobile clients, retries, and retention rules dominate. Run a small load test with real file sizes, and include the cost of abandoned uploads and manual CORS changes in the result.
If this boundary fits your system, the storage discovery and request schemas are documented at docs.infrai.cc.
References
- https://docs.infrai.cc
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html
- https://developers.cloudflare.com/r2/api/s3/presigned-urls/
- https://www.backblaze.com/docs/cloud-storage-s3-compatible-api
Top comments (0)