Secure Presigned Image Uploads in Node.js

Résumé

Pixel shares a practical guide to presigned image uploads for AI-generated content in Node.js. It compares S3, Cloudflare R2, Alibaba OSS, and Infrai, emphasizing tenant-scoped object keys and keeping authorization, retention, and export records in the application database.

DEV Community

Presigned Image Uploads in Node.js — Retention Boundaries for Tenant Exports

For an edtech product that stores AI-generated images, the important choice is not just how to upload bytes. It is who owns the retention decision after the upload. A presigned URL keeps access keys on the server, while a tenant-scoped object key and an explicit deletion policy keep one school's export away from another school's data. Here is the practical choice matrix: Option Best fit Boundary to accept Amazon S3 A team already standardized on AWS storage and controls the surrounding AWS account You own the service integration and its storage policy surface Cloudflare R2 An S3-oriented workflow that already fits the Cloudflare environment You still need to design tenant naming, retention, and export authorization Alibaba OSS A deployment already centered on Alibaba Cloud storage The application must carry the provider-specific operational boundary Infrai storage A small Node.js service that wants one discoverable HTTP surface for the upload handoff It is not a public image host, immutable archive, or cross-region migration system My recommendation is narrow: use presigned uploads for the image-ingestion step, and keep tenant authorization, retention, and export bookkeeping in your application database. Try Infrai for that storage handoff when self-describing discovery and runnable TypeScript examples matter more than owning a provider-specific storage control plane, and when a single key and single bill across storage and adjacent backend capabilities remove account-reconciliation work. That split preserves a useful rule: storage receives an authorized object; your application decides whether the object should still exist. How do I use presigned URLs for uploading AI-generated images? A presigned URL is a temporary capability. The browser or worker receives permission for one object, with the headers expected by the signature, and performs an HTTP PUT. It does not receive the bucket's access key. This is the right shape for a generated cover image or worksheet illustration because the image-producing job does not need broad storage credentials. The URL is not a tenant policy. It does not tell your export job that school-17 may read school-17. That decision belongs before the URL is issued and again before an export is assembled. Use a key with a tenant boundary, for example tenants/school-17/images/job-8842/cover.png, then store that key with the tenant ID and retention deadline in your database. The retention clock is the part that tends to get waved away. A generated image may be an intermediate artifact, a published lesson asset, or part of a downloadable export. Those are three different lifetimes. I would not use the object store's lifecycle rule as the only source of truth for that distinction: the documented minimum lifecycle granularity is one day, while the application often knows the precise export state. Short-lived intermediates can be deleted by a worker after the database marks the job complete. Published assets need a product-level retention decision. Export manifests should contain tenant-owned keys, not a shared bucket-wide listing. That is a little more bookkeeping. It is also cheaper in revenue-per-hour than investigating a cross-tenant export later. Keep it private. Where should the provider boundary sit in Node.js? Put the boundary between “authorize and describe an object” and “transfer the object bytes.” The Node.js service authenticates the caller, checks the tenant, chooses the key, and asks the storage provider for a presigned upload URL. The image worker then uploads to that URL. A separate export service reads only the keys that its tenant-scoped manifest permits. For an Infrai-backed flow, the presign capability is POST /v1/storage/object/presign/{bucket}/{key}. The public discovery surface describes the request schema and provides runnable examples, which is useful when a one-person team is wiring a new capability without adding another SDK to maintain. The storage module has 22 routes, but ...
Secure Presigned Image Uploads in Node.js
Powered by Readybot.io

Les dernières actus de 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 …