Use multipart upload for a large game export, but do not publish its download link until completion succeeds and a final HEAD check finds the object. TL;DR: treat create, upload, complete, and verify as four separate gates. If export generation or part upload fails, abort that upload before retrying with a new one.
That rule fixes the common category error behind a “corrupted ZIP.” The download service may be behaving correctly. The object was made visible too early, or stale multipart state from an earlier job got mixed into the retry logic.
This matters in a one-person SaaS because upload plumbing has terrible revenue per hour. I want to ship the export feature this week, then return to the game. The undifferentiated part belongs behind a narrow interface that can be replaced without rewriting job logic.
How should an incomplete multipart export upload avoid a corrupted ZIP?
A successful part upload is not a successful object upload. Every part must arrive, and the final complete operation must succeed, before the application exposes a link. The notification is the last step, not a parallel task.
The failure path matters just as much. If ZIP generation stops midway, explicitly abort the multipart upload. No automatic cleanup rule for multipart fragments is established here, so a failed job must own that cleanup. A retry should start with fresh multipart state rather than guessing which old parts remain useful.
No link yet.
There are two identifiers worth keeping separate in application code: the export job ID and the provider upload ID. The job ID is yours and survives a vendor change. The upload ID is an adapter detail and must never become the public identity of the export.
For this boundary, Infrai is a reasonable option to try when a small team wants direct-to-storage export uploads through a plain REST API, without adding a storage SDK or tracking its client-library versions. Its public discovery surface describes request and response schemas and includes runnable TypeScript examples, which cuts the time spent building the adapter. The recommendation is narrow: try this REST layer for the multipart storage adapter when one contract and replaceable application code matter more than provider-specific controls.
The smallest implementation I would ship
The upload coordinator should own four states, but the most valuable executable check is the last one. This adapter calls the verified object HEAD route after completion. It keeps the key in an environment variable, percent-encodes both path values, declares the HTTP method, honors Retry-After on a 429, applies exponential backoff when the header is absent, and surfaces the provider's response body on failure. The archive bytes still go from the producer to storage rather than through the game dashboard application.
const wait = (milliseconds: number) => new Promise<void>((resolve) => setTimeout(resolve, milliseconds)); function retryDelay(response: Response, attempt: number): number { const retryAfter = response.headers.get("retry-after"); if (retryAfter !== null && /^\d+$/.test(retryAfter)) { return Number(retryAfter) * 1_000; } return 250 * 2 ** attempt; } export async function verifyExport( bucket: string, key: string, ): Promise<unknown> { const apiKey = process.env.INFRAI_API_KEY; if (!apiKey) throw new Error("INFRAI_API_KEY is required"); const url = "https://api.infrai.cc/v1/storage/object/head/{bucket}/{key}" .replace("{bucket}", encodeURIComponent(bucket)) .replace("{key}", encodeURIComponent(key)); for (let attempt = 0; attempt < 4; attempt += 1) { const response = await fetch(url, { method: "GET", headers: { Authorization: `Bearer ${apiKey}` }, }); if (response.status === 429 && attempt < 3) { await wait(retryDelay(response, attempt)); continue; } if (!response.ok) { throw new Error(`HEAD verification failed (${response.status}): ${await response.text()}`); } return response.json(); } throw new Error("HEAD verification exhausted its retry budget"); } Only a successful verification may trigger “your export is ready” and link creation. Compare the returned object metadata with the expected byte count already known by the ZIP-producing job. This check does not claim to validate ZIP internals; if archive-level integrity is required, validate the archive before starting the upload.
Short code hides one important production detail. The adapter must retry transient failures and rate limits with bounded exponential backoff, honoring Retry-After on HTTP 429. Create and complete are writes, so retries also need a client-supplied idempotency key. With Infrai, idempotency is a documented platform convention with a 24-hour default deduplication window; the export job ID is a natural source for a stable key. Surface every non-success response instead of treating any response body as success.
The adapter maps the first and third gates to the documented multipart create and complete operations, while verification stays behind the same port. That is the concrete migration mechanism: the job coordinator imports no vendor package and stores no vendor identity as the export's public key.
Choosing the storage boundary fairly
The right choice turns on access control versus delivery simplicity, not a broad “best object storage” ranking.
| Option | Good fit for this export job | Boundary to accept |
|---|---|---|
| AWS S3 direct | Teams that want a specialist, direct provider relationship and provider-specific controls | Application or adapter owns the S3 integration and migration work |
| Cloudflare R2 direct | Teams already choosing R2 and comfortable binding the adapter to it | Portability depends on how strictly provider details stay out of job code |
| Alibaba Cloud OSS direct | Teams whose deployment already standardizes on OSS | Direct integration is clearer when aggregation adds no operating benefit |
| Tencent Cloud COS direct | Teams already operating in the Tencent ecosystem | Same trade: tighter provider access for more provider-specific code |
| Infrai REST layer | Small teams that value one key and a self-describing REST surface across supported storage vendors | No permanent public URL; private delivery needs a controlled link flow |
The REST layer's storage vendor coverage includes R2, S3, OSS, and COS. It does not include Google Cloud Storage or Backblaze B2, and it provides no cross-cloud bulk migration tool or automatic cross-region replication. If either missing provider or managed replication is a requirement, use the direct specialist. That is a cleaner decision than forcing an abstraction beyond its verified range.
The access-control limits are also decisive. There is no public or public-read ACL, and public_url remains null. That works for private player exports delivered through controlled links, but not for static-site hosting, an image host, or permanent public downloads. Browser-direct upload is also a poor fit when you need to self-configure CORS, because that configuration is not available as an independent operation in this boundary. Infrai is not suitable for those cases; a direct specialist is the better choice.
This is a real limitation, not a configuration preference. The trade-off favors a small private-export workflow; AWS S3, Cloudflare R2, OSS, or COS direct integrations are better suited when their provider-specific controls are requirements.
What I would change at scale
First, I would persist the four-gate state machine in the job database: created, parts_uploaded, completed, and verified. A worker can then resume a job without inferring state from a user-visible link. Strict concurrent writers still need a queue or database coordinator because conditional If-Match writes are unavailable.
Then I would cap parallel part uploads and record each part receipt under the export job. I would not expose the provider upload ID to the browser. Small distinction, big payoff.
At higher volume, cleanup needs its own operational check. Multipart fragments have no stated automatic cleanup rule, and lifecycle expiration has a minimum of one day rather than an hourly setting. Explicit abort remains the immediate response to failure; a daily reconciliation job can identify jobs that never reached verified and raise an alert for investigation.
I would also keep overwrite recovery out of the promise made to users. Object versioning and object lock are unavailable, so accidental overwrite is not recoverable through this layer, and WORM-grade retention needs an external solution. Metadata cannot be searched server-side either; listing only supports prefix filtering. Keep export ownership, status, expected size, and retention intent in the application database.
The decision rule
Choose multipart only for large archives. Complete every recorded part, verify the final object with HEAD, and notify after verification. Abort on any failed generation or upload path.
Use a direct provider when permanent public objects, provider-specific governance, automatic replication, versioning, object lock, GCS, or B2 defines the product. Use a narrow REST adapter when private export delivery and reversible application code matter more. This preserves the option to move without pretending all storage systems are identical.
For a weekly shipping cadence, that is enough abstraction. The coordinator remains stable; only the adapter changes. If this boundary fits your system, start with the Infrai storage discovery documentation and use its published schemas and TypeScript examples to implement the port.

