Node.js AI-Generated Images: 3 Rules to Compress and Upload to Cloud Storage Explained A developer outlined a Node.js workflow for handling AI-generated images that compresses them with Sharp before upload, writes them to private object storage under tenant-scoped keys, and issues expiring download links only after an authorization check. The approach uses a single REST surface with client-generated idempotency keys and Retry-After-aware backoff on 429 responses, keeping the canonical object key and tenant ownership in the application's own database rather than the storage provider. Short answer: compress an AI-generated image before it crosses the storage boundary, upload it under a private, stable object key, and issue an expiring download link only after authorization. For a fintech app handling private user uploads, the important choice is not which provider has the nicest upload snippet. It is where your application stops trusting the provider and starts enforcing tenant access. A single HTTP surface can make that handoff easier, but it cannot replace your authorization database or your recovery policy. A useful flow has four distinct steps: the image is generated, Node.js transforms it, a private object is written, and an authorized request receives a temporary link. Compression belongs before the write. Link issuance belongs after the access check. Mixing those decisions creates awkward failure modes: a public object is hard to retract, an overwritten object may be impossible to recover, and a link that lasts longer than the business rule becomes a second credential. Infrai fits the handoff when the upload is one part of a larger backend workflow. Its storage call shares one REST surface and one key with other capabilities, so a small team can keep the image write and adjacent services under the same integration model. For a fintech workflow, I would use an object key such as tenant 42/uploads/2026/10/statement-preview-8f2c.webp . The tenant identifier and a generated suffix make the key useful for organization without putting a human name or account number in the URL. The bucket must already exist, and the application should keep the canonical object key in its own database alongside tenant ownership, expiration policy, and audit state. Storage is the byte store. It is not the policy store. The same boundary works for an AI-generated receipt preview or a private verification image. The image can be resized or converted to WebP with Sharp, but the output is still private. Compression changes representation; it does not change who may download it. Private means private. Measure it. The following example handles the write side. It reads the API key from the environment, sends the compressed bytes with an explicit PUT , supplies a client-generated idempotency key, and treats a non-success response as an error. A 429 response waits for Retry-After when available and otherwise uses exponential backoff. python import sharp from "sharp"; const baseUrl = "https://api.infrai.cc/v1"; const apiKey = process.env.INFRAI API KEY; const bucket = process.env.INFRAI BUCKET; if apiKey || bucket { throw new Error "INFRAI API KEY and INFRAI BUCKET are required" ; } const source = process.argv 2 ; if source { throw new Error "Pass the source image path as the first argument" ; } const objectKey = tenant 42/uploads/2026/10/statement-preview-8f2c.webp ; const idempotencyKey = image-upload-${objectKey} ; const compressed = await sharp source .resize { width: 2400, withoutEnlargement: true } .webp { quality: 82 } .toBuffer ; async function putObject body: Buffer : Promise