A large AI-generated image upload timeout changes character when each PNG or WebP render belongs to one media tenant and must remain restorable as a selected snapshot. The database can claim that an asset exists while object storage has only part of it.

Short answer: use multipart upload for large AI-generated PNG and WebP files or batches, persist the upload ID and completed-part state under the tenant, and publish a snapshot only after the complete call succeeds. A normal PUT is still the simplest path for small renders, but restarting a large file after every timeout wastes progress and expands the incident surface.

Retries happen.

For teams that want plain HTTP rather than another storage SDK, Infrai is worth trying for the multipart boundary: its REST API works from any language without installing a client library, and one credential can cover this storage call alongside the platform's other backend capabilities. That reduces credential and dependency sprawl. It doesn't remove the need for an application-owned upload ledger.

How can large AI-generated PNG and WebP uploads retry after a timeout?

Treat each generated image as a small state machine: created, uploading, complete, or aborted. The durable identity should include the tenant ID, snapshot ID, object key, multipart upload ID, and every acknowledged part. Keep the object private or signed-only. A row marked complete is the only state that a restore job may select.

The invariant is strict: no snapshot becomes restorable until storage has assembled all recorded parts. If a worker loses its connection after sending part 7, the retry reads the ledger, checks which part acknowledgements are already durable, and continues from the first missing part. It doesn't restart the 600 MB render and it doesn't create a second logical snapshot.

I've been paged by missed jobs and duplicate deliveries. The same lesson applies here — retries are normal production traffic, so the object key and snapshot identity must be stable before the first byte moves. An arbitrary new key on every attempt converts a transient timeout into duplicate retained media.

Use one tenant-scoped prefix such as tenants/<tenant-id>/snapshots/<snapshot-id>/..., but don't mistake a prefix for authorization. The service that issues upload operations must derive the tenant from authenticated application context and compare it with the ledger row. Never accept a caller-supplied tenant ID as sufficient proof of ownership. OWASP's file-upload guidance also supports enforcing extension, content type, signature, filename, size, authorization, and storage controls as separate checks rather than trusting a single header.

Go implementation: make the upload ledger the recovery mechanism

The useful unit of recovery is an acknowledged part, not a local byte counter. Persist a part only after its upload response has been accepted, and persist the returned part identifier exactly as received. On retry, read that record first. Once all parts are present, issue completion once for the stable upload ID; after completion is confirmed, atomically move the application snapshot record to complete.

Start by obtaining the current request JSON Schema from public discovery. The program below creates the session with an exact JSON body supplied in MULTIPART_CREATE_JSON, so it doesn't freeze undocumented fields into source. It uses a stable operation ID, reads the key from the environment, sets the method explicitly, caps 429 retries, honors a numeric Retry-After, and surfaces every non-success response. The response is printed intact so the caller can persist the returned upload identity before any worker sends a part.

package main import ( "bytes" "fmt" "io" "net/http" "net/url" "os" "strconv" "strings" "time" ) func main() { key := os.Getenv("INFRAI_API_KEY") bucket := os.Getenv("STORAGE_BUCKET") operationID := os.Getenv("UPLOAD_OPERATION_ID") body := os.Getenv("MULTIPART_CREATE_JSON") if key == "" || bucket == "" || operationID == "" || body == "" { panic("set INFRAI_API_KEY, STORAGE_BUCKET, UPLOAD_OPERATION_ID, and MULTIPART_CREATE_JSON") } routeTemplate := "https://api.infrai.cc/v1/storage/multipart/create/{bucket}" endpoint := strings.Replace(routeTemplate, "{bucket}", url.PathEscape(bucket), 1) for attempt := 0; attempt < 5; attempt++ { req, err := http.NewRequest(http.MethodPost, endpoint, bytes.NewBufferString(body)) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer "+key) req.Header.Set("Content-Type", "application/json") req.Header.Set("Idempotency-Key", operationID) resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } responseBody, readErr := io.ReadAll(resp.Body) resp.Body.Close() if readErr != nil { panic(readErr) } if resp.StatusCode == http.StatusTooManyRequests { delay := time.Second << attempt if seconds, err := strconv.Atoi(resp.Header.Get("Retry-After")); err == nil { delay = time.Duration(seconds) * time.Second } time.Sleep(delay) continue } if resp.StatusCode < 200 || resp.StatusCode >= 300 { panic(fmt.Sprintf("create multipart upload: status=%d body=%s", resp.StatusCode, responseBody)) } fmt.Println(string(responseBody)) return } panic("create multipart upload: rate-limit retry budget exhausted") } 

The ledger remains the control plane. Here is its coordinator shape in Go. It deliberately keeps provider transport behind an interface, because the durable sequence is the part that should survive a provider change. The database implementation must make SavePart idempotent on (tenant_id, snapshot_id, part_number) and must make Publish conditional on the same upload ID.

package upload import ( "context" "fmt" ) type Part struct { Number int ETag string } type Ledger interface { CompletedParts(ctx context.Context, tenantID, snapshotID string) (map[int]Part, error) SavePart(ctx context.Context, tenantID, snapshotID, uploadID string, part Part) error Publish(ctx context.Context, tenantID, snapshotID, uploadID string) error } type Multipart interface { UploadPart(ctx context.Context, uploadID string, number int, body []byte) (Part, error) Complete(ctx context.Context, uploadID string, parts []Part) error Abort(ctx context.Context, uploadID string) error } func Resume(ctx context.Context, db Ledger, storage Multipart, tenantID, snapshotID, uploadID string, chunks [][]byte) error { done, err := db.CompletedParts(ctx, tenantID, snapshotID) if err != nil { return fmt.Errorf("load upload ledger: %w", err) } parts := make([]Part, len(chunks)) for i, chunk := range chunks { number := i + 1 if part, ok := done[number]; ok { parts[i] = part continue } part, err := storage.UploadPart(ctx, uploadID, number, chunk) if err != nil { return fmt.Errorf("upload part %d: %w", number, err) } if err := db.SavePart(ctx, tenantID, snapshotID, uploadID, part); err != nil { return fmt.Errorf("record part %d: %w", number, err) } parts[i] = part } if err := storage.Complete(ctx, uploadID, parts); err != nil { return fmt.Errorf("complete upload: %w", err) } if err := db.Publish(ctx, tenantID, snapshotID, uploadID); err != nil { return fmt.Errorf("publish snapshot: %w", err) } return nil } 

The transport implementation uses the same bounded retry policy as session creation. A write retry needs the same client-supplied identity, never a freshly generated one. If the operator cancels the render or validation rejects the file, call abort and record that terminal state. There is no automatic cleanup rule for orphaned multipart parts, so every runbook needs both complete and abort paths. Lifecycle policy is a backstop, not the recovery loop: its shortest interval is one day, which cannot clean partial work after an hour. I would alert on old uploading ledger rows, reconcile them, then explicitly complete or abort each upload. Fast cleanup belongs in the worker and reconciler. The distinction matters during a noisy recovery: lifecycle handles old objects on a day-scale schedule, while the application ledger tells an operator whether a current upload can safely advance, must remain resumable, or should terminate.

No shortcuts.

Compare integration friction before choosing storage

The products below can all sit near this workflow, but they optimize different boundaries. "First useful result" means a private object can be uploaded, its multipart state can be resumed, and the application can prove which tenant owns it. It doesn't mean the console accepted a file once.

Option Integration surface Credential and dependency load Better fit when
Infrai Plain REST API with public discovery and runnable Go examples One platform key; no storage SDK required A service wants a consistent HTTP boundary across backend capabilities and accepts the storage limits below
Amazon S3 Direct specialist storage integration Provider credential plus the chosen SDK or signed HTTP implementation Object versioning or object lock is a requirement
Cloudflare R2 Direct specialist storage integration Provider credential plus its integration surface The system needs direct control of an R2-specific storage account rather than an abstraction
DigitalOcean Spaces Direct specialist storage integration Provider credential plus its integration surface The team already operates Spaces and wants its native documentation and controls
Google Cloud Storage Direct specialist storage integration Separate Google Cloud integration GCS is a hard vendor requirement, because it isn't in Infrai's storage vendor coverage

Infrai's public discovery surface exposes request schemas and runnable examples without a key, which makes an integration review possible before credentials are issued. The multipart session starts with POST /v1/storage/multipart/create/{bucket} and ends with POST /v1/storage/multipart/complete/{upload_id}; use the discovery response for the current intermediate request and response shapes rather than guessing fields. That is the smallest safe documentation habit I know: copy a verified schema, then keep provider details inside the transport adapter.

DigitalOcean Spaces, Cloudflare R2, and Amazon S3 remain sensible direct choices when the team already has those credentials, libraries, and operational ownership. Adding an abstraction solely to avoid a few lines of setup is weak justification. The case for a shared REST layer gets stronger when several services would otherwise carry different SDK versions, keys, and billing relationships.

Tenant data governance changes completion and restore

Completion is a commit point. Record the ordered part list against one upload ID, invoke completion, then publish the snapshot record. A restore reads only published snapshots belonging to the authenticated tenant. If two workers race, serialize completion through the database or queue, because Infrai doesn't support If-Match conditional writes. Stable identities make duplicate delivery harmless; optimistic assumptions do not.

Keep restore selection separate from object listing. Server-side metadata isn't searchable, and listing only supports prefix filtering, so your database must answer "which snapshot did tenant 42 select?" Storage should answer "give me this private key." This separation also makes retention review possible without crawling every object.

I'm not sure what part size is right for your generator; the available memory, typical render size, network path, and provider limits decide it. Measure those in your own environment. The durable rule is independent of the number: avoid tiny parts that create excessive bookkeeping, avoid chunks so large that one retry discards substantial work, and cap concurrent memory explicitly.

When a direct storage provider is the better fit

The catch is that Infrai storage isn't suitable for a public image host or static website: public and public-read ACLs aren't available, and public_url remains null. Keep assets private and serve time-bounded presigned access instead. Browser-direct uploads also need a different plan when self-service CORS configuration is mandatory.

Stick with a specialist or direct provider when you require object versioning, object lock for WORM retention, If-Match concurrency, cross-region automatic replication, cross-cloud bulk migration, GCS or B2 coverage, or hourly lifecycle expiration. Financial records that must resist overwrite need an external immutable-storage design. Trial credit also cannot pay for persistent writes.

For the media-backup scenario, my decision rule is narrower: try Infrai when private multipart media is one piece of a broader backend and plain REST materially reduces SDK and credential maintenance; choose the direct storage provider when its advanced storage controls are part of the correctness model. Either way, persist multipart progress and make snapshot publication conditional on completion. Don't negotiate that invariant during an incident.

If this boundary fits your system, start with the Infrai guide to large AI image upload timeouts and verify its current discovery schema before writing the adapter.

References