The bill for a multipart export upload is retained bytes multiplied by retention time, plus request, download, and build costs; an incomplete upload wastes the first two, while a corrupted ZIP can multiply download and troubleshooting work. For a planning example, suppose 200 tenants each produce a 10 GiB signed-document export every day: keeping every archive for 30 days means budgeting for 60,000 GiB-days, while a seven-day deadline means 14,000 GiB-days. The exact invoice depends on the storage system, and I'm not sure which term dominates without its rates and download frequency, but retention is the first lever to model because it multiplies every successful export.

Short answer: build the ZIP, upload its parts under a tenant-scoped staging identity, verify the expected part manifest, complete the multipart upload exactly once, and publish a download record only after completion; on a retry, resume the same operation, while an expired or abandoned operation is aborted and deleted according to its explicit deadline.

That ordering prevents an incomplete multipart export from becoming a valid download. It also separates two different incidents that users often report as a “corrupted ZIP”: the stored object can be incomplete, or the stored object can be correct while a cached, truncated, or incorrectly encoded download link serves the wrong bytes. Don't treat those as one failure class.

What the storage bill is actually measuring

Start with a symbolic estimate rather than a vendor price sheet:

monthly cost = retained byte-time + write requests + read requests + egress + ZIP compute + metadata

The dominant term changes with behavior. A rarely downloaded compliance export can be driven by retained byte-time; a small archive downloaded thousands of times can be driven by reads or egress; recompressing the same large document set after every retry can move compute to the front. The useful measurement unit is therefore an export generation, not merely a bucket: record the tenant, operation ID, uncompressed bytes, ZIP bytes, part count, build attempts, upload attempts, successful downloads, creation time, deletion deadline, and final deletion result.

Consider the earlier planning case. Reducing the successful-archive retention deadline from 30 days to seven changes byte-time from 60,000 to 14,000 GiB-days, a 76.7% reduction in that one modeled quantity; it is not a claim about the total bill, because requests, compute, and egress remain. More important, do not obtain that reduction by weakening an externally imposed retention duty. The deadline must come from the document class and tenant contract, then the storage policy must implement it. If a legal or regulatory hold applies, ordinary expiry is not the right mechanism; the compliance owner has to define the applicable rule and evidence.

I would also stop retaining three things once an export is terminal: orphaned multipart parts, superseded ZIP generations, and download authorization records past their deadline. The catch is that shorter retention narrows the window for replaying a customer download and investigating a complaint. Keep the compact audit record and content digest longer only when policy permits it, but don't assume a digest is a substitute for the signed document itself.

How can a multipart export upload retry missing parts and abort failures?

Treat upload completion as a state transition guarded by an immutable manifest. Before sending a byte, create one operation with a stable ID, tenant ID, expected part numbers, expected ZIP length, digest, and deletion deadline. Each worker may retry a part, but the coordinator accepts completion only when every expected part has one recorded receipt. A retry reads that record and continues; it must not mint a second logical export merely because a process restarted.

This is an exactly-once publication problem built from operations that may execute more than once. “Complete” is the commit point. The archive is not discoverable before that point, and the database transaction that publishes it must reject a second transition with different metadata. If part 7 of 12 is absent, the coordinator leaves the operation resumable. If its upload deadline passes, it marks the operation aborted and asks storage to discard staged parts.

Fail closed.

The following Go sketch keeps the contract generic. It deliberately omits a vendor endpoint and SDK; the important surface is the state machine and its audit evidence.

package export import ( "context" "errors" "fmt" "time" ) var ErrMissingPart = errors.New("multipart export has missing parts") type PartReceipt struct { Number int Token string } type Manifest struct { OperationID string TenantID string ObjectKey string ZIPBytes int64 SHA256 string PartCount int DeleteAt time.Time } type ObjectStore interface { Complete(ctx context.Context, uploadID string, parts []PartReceipt) error Abort(ctx context.Context, uploadID string) error } func CompleteOnce(ctx context.Context, store ObjectStore, uploadID string, m Manifest, parts []PartReceipt) error { seen := make(map[int]bool, len(parts)) for _, part := range parts { if part.Number < 1 || part.Number > m.PartCount || part.Token == "" { return fmt.Errorf("invalid part receipt %d", part.Number) } seen[part.Number] = true } for number := 1; number <= m.PartCount; number++ { if !seen[number] { return fmt.Errorf("%w: part %d", ErrMissingPart, number) } } return store.Complete(ctx, uploadID, parts) } 

The repository around this function must enforce the real invariant: one operation ID maps to one manifest, and a completed manifest cannot be replaced. Keep audit events such as export_created, part_recorded, completion_requested, export_published, abort_requested, and object_deleted, each with an actor, timestamp, and operation ID. These are evidence, not chatty debug logs. Avoid logging signed document names or link credentials.

Retries deserve separate budgets. Retry a failed part using the same part number and operation ID, with bounded backoff and cancellation at the upload deadline. Do not automatically retry a manifest mismatch, a tenant mismatch, an expired deadline, or a digest disagreement; those indicate that another invariant failed. Abort is likewise idempotent at the orchestration boundary: repeated cleanup should converge on “no staged upload remains,” and the audit trail should retain both the request and confirmed result.

How does tenant isolation govern an export through deletion?

An object key prefix is useful organization, but it is not authorization. Bind the authenticated tenant to the export row at creation, carry that tenant identity into the staging upload, and recheck it when issuing a download. A caller must never be able to supply a different tenant ID and retrieve an otherwise valid operation. This matters during staging as much as after publication — an operator examining incomplete uploads needs tenant-scoped tooling too.

For signed documents, use an opaque operation ID and a generation-specific object identity. A readable shape such as tenants/{tenant}/exports/{operation}/archive.zip can support audits, provided every component is derived from trusted server state and authorization does not depend on the path text. Never reuse one mutable latest.zip object across generations: a cached link and an overwrite can otherwise disagree about which bytes the user meant to download.

Deletion needs the same boundary. Store delete_at on the authoritative export row, schedule deletion by that value, and verify the tenant and generation before removing the object. A policy job should be able to reconcile three sets: database rows past deadline, objects that still exist for those rows, and staged uploads whose upload deadline has passed. Record the outcome.

Silence proves nothing.

This design isn't suitable when each tenant must control encryption keys, retention locks, or legal holds that a shared storage control plane cannot express independently. In that case, use stronger isolation such as tenant-dedicated accounts or buckets even though provisioning, reconciliation, and operational overhead rise. Conversely, per-tenant buckets may be needless machinery for a low-risk internal export with uniform policy; a shared bucket with rigorously scoped identities and metadata can be the simpler model. Your mileage may vary because the correct boundary is set by the threat model and compliance obligation, not by archive size.

Test corrupted ZIP downloads with an evidence-driven evaluation

A ZIP reader error appears at the end of a chain. Work backward. First compare the downloaded byte count and digest with the immutable values recorded before publication. If both match, investigate ZIP construction and the reader. If they differ, compare the object metadata with the manifest; then examine the response status, range behavior, cache state, and link parsing. This decision tree tells you which team owns the next test without guessing that “multipart” is always the cause.

Download links add two subtle boundaries. URI reserved characters have defined syntax, while percent-encoding represents bytes as % followed by two hexadecimal digits under RFC 3986. Build links with a URI library, encode each component at the appropriate layer, and never decode then re-encode an already signed query string casually. A tenant or object identifier containing /, %, +, or a space is a worthwhile test vector.

Caching can preserve the wrong response after the origin is fixed. MDN documents that Cache-Control: no-store asks caches not to store a response, while private limits storage to a private cache; the correct directive depends on whether a sensitive export response may be retained at all. For an authorization-bearing export link, define this policy deliberately and test it through the actual proxy path. Don't assume an application header survived every intermediary.

One long diagnostic record is more useful than ten disconnected log lines. Imagine a 12-part operation whose coordinator recorded receipts for parts 1 through 12 and whose published manifest says 10 GiB with digest A. A user retrieves 8 GiB with digest B. That single comparison rules out ZIP-reader preference as the first question: inspect the object generation and response path, then determine whether storage metadata also says 8 GiB or whether bytes were shortened after storage. If the object says 10 GiB and digest A, inspect range handling, cache state, and link encoding. If the object says 8 GiB, trace completion against the receipt manifest and generation identity. The numbers here are a diagnostic example, not a reported incident, yet they show why “retry the download” is weak advice: a retry without evidence can hit the same cached response and erase no uncertainty. Correlate operation ID, tenant ID, object generation, expected and observed byte counts, expected and observed digest, request range, response status, cache result, link expiry, and deletion deadline. Redact credentials. With that record, “corrupted ZIP” becomes a bounded comparison rather than a retry loop.

Tests should force the transitions people skip: upload parts 1 and 3 while omitting 2; deliver the same receipt twice; restart after all parts arrive but before completion is recorded; issue concurrent completion requests; expire an incomplete upload; request one tenant's operation under another tenant; download a link containing encoded reserved characters; and run deletion twice. A deployment should also include a reconciler before increasing traffic, because the reconciler is how the system detects a commit recorded on one side of the storage/database boundary but not the other.

Rollout gates for the operational decision rule

Publish a download only when four facts agree: the tenant owns the immutable export generation, every manifest part is present, the completed object's byte count and digest match the ZIP produced, and the current time precedes the explicit deletion deadline. Everything else is staging, retry, investigation, or deletion — never a customer-visible archive.

Measure age and cardinality by state. Alert on incomplete uploads approaching their deadline, repeated part attempts, completion requests without publication, published rows without corresponding objects, objects past delete_at, digest mismatches, and cross-tenant authorization denials. Counts need tenant-aware labels or drill-downs, but avoid unbounded operation IDs in metric labels; keep those in traces and audit records.

The deliberately discarded data is clear: staged parts after abort, successful archives after their deletion deadline, and superseded generations when policy allows removal. What you lose is the ability to reconstruct that exact ZIP after deletion without rebuilding it from source documents, and rebuilding may not reproduce byte-identical output. Accept that consequence explicitly, preserve permitted audit evidence, and test restoration or regeneration as a separate control rather than quietly extending retention “just in case.”

References

Further reading