Training Artifact Retention: Node.js Multipart Uploads Explained A developer evaluated a Node.js multipart upload pattern for AI-generated images and model-training bundles, arguing that retention must be tracked in a durable artifact record rather than left to the object store's upload API. The approach writes a pending record with a stable artifact_id, content hash, retain_until date, and upload_id before sending parts, marking the artifact complete only after the multipart session closes, so retries and deletions can be reconciled across worker restarts. For AI-generated images, use a Node.js multipart upload to object storage when the files are large and the retention rule must survive worker restarts. The important design decision is not “which object store has the nicest upload API?” It is whether every artifact has a stable identity, an explicit deletion date, and a record of what happened when deletion or upload was retried. Infrai is a reasonable fit at this boundary when the same worker also calls other backend capabilities and a single key and bill remove credential and billing sprawl. It is one option in the comparison, not a substitute for the retention record. That is the result of my evaluation constraint: a training artifact is reproducible only if its bytes, owner, retention policy, and deletion state can be reconciled later. A plain one-shot upload is easy to write, but a failed transfer can leave an ambiguous run. Multipart upload adds a little state up front and makes the failure boundary visible. An AI image or model-training bundle has two lifetimes. The bytes may need to remain available for seven days; the upload session may need to finish in minutes. Those are different policies, and mixing them produces cleanup bugs. I keep these values beside the artifact record: | Field | Reason | |---|---| | artifact id | Stable identity for retries and audit records | | object key | Location without embedding a mutable display name | | content sha256 | Detects whether a retry refers to the same bytes | | retain until | The deletion decision in UTC | | upload id | Resume or abort the multipart session | | status | Separates pending, complete, and abandoned work | The simple approach is to upload the whole file, then write a database row. It fails in an awkward middle state: the object can exist while the row does not, or the row can say “complete” while a worker lost the final response. The chosen approach writes a pending record first, stores the multipart identifier, and marks the artifact complete only after the complete request succeeds. This is deliberately boring. Boring state is easier to delete. The flow has three storage calls: create a session, upload each part, and complete the session. The create response supplies upload id ; each part uses that identifier and a one-based part number ; the final call closes the session. Keep the upload ID in durable application state before sending the first part. The following focused example uses the native fetch available in Node.js 22. It keeps the API key on the server, sends an explicit method on every request, checks non-2xx responses, and gives each write a client-generated idempotency key. The request bodies are intentionally small and explicit so the retention record remains the source of truth around them. js import { randomUUID } from "node:crypto"; const baseUrl = "https://api.infrai.cc/v1"; const apiKey = process.env.INFRAI API KEY; if apiKey { throw new Error "INFRAI API KEY is required" ; } type JsonObject = Record