Short answer: keep every generated image private, stream bytes directly into object storage, and let an authenticated control plane issue narrowly scoped, expiring download URLs only after it has checked tenant ownership and object state.

For a fintech backend, the decisive constraint is large-file throughput rather than the convenience of a particular SDK. The application process shouldn't buffer a 200 MB artifact, shouldn't treat possession of an object key as authorization, and shouldn't claim success before durable object state and the audit record agree. A signed URL is a temporary capability, not an access-control system.

That distinction drives the whole design.

What should a Node.js service require when storing AI-generated images in a private bucket?

The runtime at the control-plane boundary can be Node.js, but the storage contract should remain independent of it: an upload has an immutable tenant, an expected media type and size, an idempotency key, and a lifecycle state; a download grant names one committed object, one requesting principal, and one short expiry. The examples below use Go, as a compact way to express that contract without tying it to a commercial SDK.

Start with two paths. On the data path, the producer streams image bytes to private object storage, preferably without routing the entire payload through a memory buffer. On the control path, the service authenticates users, authorizes tenant access, allocates opaque object keys, records state transitions, and creates expiring download grants. Keeping those paths distinct prevents a burst of large images from consuming the same resources that serve authorization and ledger traffic.

The bucket stays private. Always.

An object key such as tenant-42/2026/08/7f3c... is an address, not proof that the caller may read the object. Before issuing a URL, the application must resolve the object through its own metadata record and verify that the authenticated tenant owns it, that the upload reached committed, and that retention policy has not made it unavailable. The generated URL should permit only the required read operation and should expire quickly enough for the business risk; there is no universally correct lifetime, because a support workflow and an interactive preview have different tolerances.

The browser is a separate trust boundary. If it uploads or downloads across origins, configure CORS for the exact application origins, methods, and headers that are required. CORS controls which browser origins may read a response; it doesn't replace authentication, tenant authorization, or a private bucket policy.

Stream the payload, but commit the intent first

Large-file throughput fails quietly when an innocent-looking helper reads the full body into memory. Fifty concurrent 200 MB images imply 10 GB of live payload before allocator overhead, retries, or other requests enter the calculation. The precise breaking point varies by runtime and deployment — I'm not sure any static threshold deserves to be called safe — so the useful rule is architectural: apply a hard size limit, preserve backpressure, and avoid full-body buffering.

Create the metadata row before moving bytes, using a unique constraint on (tenant_id, idempotency_key). The first accepted request allocates the opaque storage key and enters pending; a retry with the same key returns the same upload identity, while reuse with materially different metadata returns 409 Conflict. This is an exactly-once mindset implemented over at-least-once delivery: retries may happen, but one logical request gets one durable identity and one auditable outcome.

The storage adapter can stay deliberately small:

package images import ( "context" "io" "time" ) type ObjectStore interface { Put(ctx context.Context, key, contentType string, body io.Reader, size int64) error SignRead(ctx context.Context, key string, expires time.Duration) (string, error) } type UploadIntent struct { ID string TenantID string ObjectKey string IdempotencyKey string ContentType string ExpectedBytes int64 State string } 

io.Reader matters here because it allows the handler to pass a bounded request body, a generator stream, or a temporary-file reader without forcing a second complete copy. The adapter is also the right boundary for multipart behavior when objects are large enough to need it. Multipart part size, parallelism, retry policy, and completion semantics belong in deployment configuration and focused tests, since optimal values depend on object-size distribution, network bandwidth, and the chosen storage implementation.

Do not mark the row committed merely because all bytes left the process. The transition belongs after the storage operation reports success and after the service has recorded the final size and a content digest when the storage contract exposes enough information to verify one. If the process loses its database connection between those operations, a reconciler should compare old pending intents with storage state and either finish the transition or expire the intent according to policy. It shouldn't guess from a client retry.

This is the awkward part, but it is also where auditability comes from: the database and object store do not share a transaction, so the design needs explicit intermediate states rather than an imaginary distributed commit.

Make download authorization a ledger event

A download endpoint should accept an application object ID, never a raw storage key supplied by the caller. Resolve the row under the authenticated tenant, authorize the purpose, and then ask the storage adapter for a read-only URL with a bounded lifetime. The response may include the expiry time, but logs must not contain the URL itself; its query string is a bearer capability until it expires.

package images import ( "context" "errors" "time" ) var ErrNotFound = errors.New("image not found") type Image struct { ID string TenantID string ObjectKey string State string } type ImageRepository interface { FindCommitted(ctx context.Context, tenantID, imageID string) (Image, error) AppendGrant(ctx context.Context, imageID, actorID, purpose string, expiresAt time.Time) error } func GrantDownload( ctx context.Context, repo ImageRepository, store ObjectStore, tenantID, actorID, imageID, purpose string, now time.Time, ) (string, time.Time, error) { image, err := repo.FindCommitted(ctx, tenantID, imageID) if err != nil || image.State != "committed" { return "", time.Time{}, ErrNotFound } expiresAt := now.Add(5 * time.Minute) url, err := store.SignRead(ctx, image.ObjectKey, time.Until(expiresAt)) if err != nil { return "", time.Time{}, err } if err := repo.AppendGrant(ctx, image.ID, actorID, purpose, expiresAt); err != nil { return "", time.Time{}, err } return url, expiresAt, nil } 

Production code should calculate the duration from the same injected clock used for expiresAt; the abbreviated example keeps the authorization sequence visible. More important, decide the audit guarantee explicitly. If policy says no capability may exist without a durable grant event, reserve a grant record first, issue the URL, and finalize the record; a recovery job can close abandoned reservations. Recording only after returning the response leaves a compliance gap. Logging actor, tenant, object ID, purpose, requested lifetime, decision, and expiry produces useful evidence without persisting the credential.

Expiration limits future use but cannot revoke a URL already issued. Don't pretend otherwise. When immediate revocation is mandatory, put an authenticated application or edge proxy on the read path and accept the extra bandwidth, latency, and operational load; stick with direct signed downloads when bounded capability lifetime is acceptable and keeping large payloads off the application tier matters more.

Compare architectures by throughput and control

The relevant comparison is not a feature checklist. It is which component carries bytes, where authorization runs, and what can be proved afterward.

Pattern Large-file throughput Authorization and audit Best fit Limitation
Application proxy Every byte crosses the service Can evaluate every read and stop access immediately Strict revocation or response transformation Application bandwidth and connection capacity become the data-plane ceiling
Private storage plus expiring URL Storage serves bytes after a control-plane decision Grant creation is auditable; use after issuance is bounded by expiry High-throughput downloads with short-lived access An issued capability cannot be recalled by the application
Public object with an obscure key Storage serves bytes directly Possession becomes authorization Public, non-sensitive assets only Not suitable for private user uploads

The middle pattern is usually the balanced answer for generated financial-document previews and other private images because the authorization service remains authoritative without carrying the payload. The catch is the revocation boundary. A five-minute grant still has a five-minute exposure window, and reducing that window increases signing traffic and the chance that slow clients need a fresh grant. Choose the duration from threat model, object size, and client behavior, then record the choice as policy rather than scattering constants through handlers.

Cost belongs in this decision, but it isn't a proxy for correctness. Model stored bytes over retention time, write and read requests, data transfer, incomplete multipart uploads, reconciliation scans, and the application egress avoided or incurred by the chosen path. Provider pricing dimensions can change, so keep them in a versioned worksheet linked to current primary pricing documentation rather than embedding a per-request number in code.

Error handling should preserve the same boundaries. Return 413 Payload Too Large before accepting an upload beyond policy, use 409 Conflict for incompatible reuse of an idempotency key, and collapse cross-tenant lookup failures into 404 Not Found so the endpoint doesn't become an object-existence oracle. Retry transient storage operations only when the operation and idempotency contract make repetition safe. A blind retry after an ambiguous multipart completion is not evidence of exactly-once storage.

Roll out with invariants, reconciliation, and load tests

Begin with a shadow metadata path that records intent without changing delivery, then backfill existing objects into the ownership table and compare counts, sizes, and tenant mappings. Next, enable private reads for an internal cohort, issue short-lived grants, and watch authorization denials, grant latency, bytes streamed through each path, old pending rows, and reconciliation outcomes. Only then remove legacy public access.

Test the invariants, not merely the happy request. Concurrent retries with one idempotency key must produce one object identity; a different tenant must never receive a grant for it; an uncommitted object must remain unreadable; an expired grant must fail according to the storage service's documented behavior; and a process interruption between byte transfer and metadata commit must converge through reconciliation. Load tests should use the actual size distribution, including the large tail, while measuring memory, open connections, and control-plane latency separately.

Keep rollback boring: preserve the old metadata lookup until the new ledger is reconciled, but never restore public bucket access as a shortcut. Compliance review should cover retention, deletion holds, regional requirements, access-log handling, and whether URL-bearing logs or analytics can leak capabilities. Those limits are jurisdiction- and policy-specific; engineering cannot infer them from the storage API.

Ship when the evidence balances.

References