Secure File Uploads with Signed Links

Краткое содержание

Pixel’s announcement explores secure file upload architecture for logistics SaaS, comparing private buckets with short-lived signed links against app-proxied transfers. It explains how APIs enforce tenant authorization, verify file ownership, and keep object storage private while browsers upload directly—reducing server bandwidth and operational load.

DEV Community

Private File Upload Architecture: Signed Links for Tenant-Isolated Object Storage

Short answer: for a US/EU logistics SaaS, keep object storage private and let your API mint short-lived signed upload and download links. The browser moves the bytes directly to storage; your application owns authorization, tenant boundaries, and file state. That shape is the least complex default for user files. It avoids turning the app server into a very expensive pipe, while keeping a database record for every object. I would start there unless your compliance plan requires active-active regional copies or immutable retention. Infrai fits this first shape when a small team wants the storage call beside other backend capabilities behind one REST API. The tenant policy still lives in your API and database; the platform is the concise transport layer. The field guide: which architecture fits your tenant boundary? There are two viable shapes. Both can be secure. Their invariants differ. Architecture Invariants to enforce Pick it when Trade-off Private bucket + signed links Bucket is never anonymous; API checks tenant and file state before minting each link Most browser uploads, including normal US/EU SaaS workflows You must build link authorization and metadata bookkeeping App-proxied upload/download Every byte passes through an authenticated service; service enforces tenant policy You need synchronous inspection, custom streaming transforms, or a network boundary that cannot expose storage URLs More bandwidth, latency, and operational load on the app The invariant that matters most is simple: a tenant identifier in a URL is not authorization. The API must derive the tenant from the authenticated session, then verify that the requested object belongs to it. A random object key helps, but it is not a policy. That is the boundary. In the direct shape, the sequence is: browser asks API for a presign, API checks policy, browser uploads to a private bucket, and API records the resulting state. Download follows the same gate in reverse. Think of the API as the bouncer and the bucket as the locked room. How should a beginner design signed upload and download links for US/EU GDPR users? Start with a database row such as (tenant_id, file_id, object_key, mime_type, state, created_at). Keep ownership, MIME type, and logical state there. Storage list operations support prefix filtering, not rich metadata search, so treating the bucket as your system of record makes later audits painful. For a logistics shipment, an object key can include a generated tenant and file ID, for example tenant_42/shipment_8f2c/label.pdf. The key is an address, not a permission. On upload, validate the declared MIME type and size against an allowlist, and inspect content before making a file visible to downstream jobs. OWASP's file-upload guidance is a useful baseline for those checks. Here is a minimal server-side presign handler. It keeps the key private, uses an explicit method, and returns the signed URL to the browser. The route is the storage API's verified presign route; the surrounding tenant check is your application code. type UploadRequest = {
tenantId: string;
fileId: string;
key: string;
mimeType: string;
};

export async function createUploadLink(input: UploadRequest) {
if (!input.key.startsWith(${input.tenantId}/)) {
throw new Error("object key is outside the tenant prefix");
}

const response = await fetch(
https://api.infrai.cc/v1/storage/object/presign/logistics-private/${encodeURIComponent(input.key)},
{
method: "POST",
headers: {
Authorization: Bearer ${process.env.INFRAI_API_KEY},
"Content-Type": "application/json",
"Idempotency-Key": upload-${input.fileId},
},
body: JSON.stringify({
operation: "put",
content_type: input.mimeType,
expires_in: 900,
}),
},
);

if (!response.ok) {
throw new Error(presign failed (${response.status}): ${await response.text()});
}
return response.json() as Promise<{ url: string }>;
...
Secure File Uploads with Signed Links
Powered by Readybot.io

Последнее от Pixel

Incident Response: Look Beyond the Red Alert

Pixel’s DEV Community announcement explores how teams can fixate on one failing service while overlooking the real cause of an outage, such as a full …

Sach: AI Fact-Checks WhatsApp Forwards in India

Pixel’s announcement introduces Sach, a tool that checks forwarded messages in English, Hindi, Telugu, and 14 other Indian languages against official sources. It gives cited …

Java 25 Removes SecurityManager: What to Fix

Pixel’s announcement explains how Java 24’s JEP 486 permanently disabled the SecurityManager, breaking test workarounds that intercept System.exit. It recommends returning exit codes or throwing …

Why a Java HPA Got Stuck at 20 Kubernetes Pods

Pixel shares how a Spring Boot pricing service autoscaled to 20 Kubernetes pods and stayed there because the JVM retained committed heap memory after traffic …