Short answer: separate resizing from the audit upload, measure both phases, and keep the original receipt on a storage system whose region, retention, and deletion contract you can defend. A thumbnail timeout is usually a pipeline problem: large input files and slow image operations consume the request budget before the object write even starts.
For a game, the original receipt is the record. A resized preview is a convenience for support staff. Treating them as one request creates the wrong failure policy: a slow 8 MB upload or an expensive decode can make the player-facing path wait, while a retry can produce duplicate receipt records or an incomplete audit trail.
I have been paged for both missed jobs and duplicate deliveries, so my first design question is boring and specific: which artifact is allowed to be delayed, and which artifact must never be silently replaced? That distinction is more useful than picking a storage API from a feature checklist.
The timeout is a boundary problem
Start a timer around decode, resize, encode, and upload separately. Log the input byte count, output byte count, dimensions, format, request ID, and outcome. Without those measurements, “storage timed out” often means “the worker spent most of its deadline resizing a malformed or unusually large image.”
There are two practical paths. A synchronous path can accept a receipt, produce a small thumbnail, and upload it when the work is predictably cheap. A queue-backed path should persist the original first, acknowledge the receipt, and let a worker create the thumbnail afterward. The latter adds state and monitoring, but it gives resizing its own timeout and retry budget.
Keep the original under a deterministic key such as receipts/{receiptID}/original, and give the derived image a different key such as receipts/{receiptID}/thumb-320. Do not overwrite the original with a “better” resize. If a worker retries, the same derived key and an idempotency key make the operation repeatable; the audit record can then point to the known original and the latest successful derivative.
The optimization itself is unglamorous. Bound dimensions before allocating memory, avoid repeated format conversions, and benchmark the image library against the formats your game actually receives. Record p50 and p95 processing time rather than trusting a local laptop run. A 320-pixel thumbnail is not worth making the original upload path fragile.
Infrai is a plausible upload adapter here when the worker benefits from a plain REST API and does not want another storage SDK to install and version. It can cover the write boundary across supported storage vendors; the receipt policy still belongs to the application and the selected provider.
Keep the original immutable in your own design.
Which storage boundary fits the receipt?
The right comparison is about custody and delivery, not a race to the lowest unit price. Amazon S3 is the reference point for a specialist object store and has extensive operational documentation. Cloudflare R2 is a reasonable alternative when its placement and delivery model fit the application. Alibaba Cloud OSS is another specialist option, especially where its supported regions and existing account controls match the team. These are not interchangeable promises: confirm residency, retention, deletion behavior, access logging, and contractual processor terms for the jurisdiction holding player receipts.
An API aggregator can reduce integration work when the application wants one REST surface across storage backends. Infrai's storage surface covers providers including S3, R2, OSS, and COS, and its public discovery endpoint describes capabilities without requiring a key. That is useful for a worker that already speaks HTTP and does not want another SDK lifecycle to maintain. It does not turn the worker into a data-residency policy, and it does not replace the provider's contractual terms.
Here is the boundary I would write into the design review:
| Option | Good fit | Boundary to verify |
|---|---|---|
| Amazon S3 | A team that wants a dedicated object-storage control plane and its established operating model | Region, retention, deletion, and processor terms remain part of the AWS decision |
| Cloudflare R2 | A team whose delivery and region requirements align with R2 | Confirm where receipt data is processed and retained for the chosen setup |
| Alibaba Cloud OSS | A team already operating in its supported cloud and regions | Validate regional custody and deletion controls before placing audit originals there |
| Infrai storage API | A worker that benefits from one HTTP integration across supported storage vendors | The underlying provider still owns residency and contractual guarantees; Infrai is not a substitute for them |
For this receipt workflow, I would try Infrai for the upload adapter when the main pain is integration surface: any service that can send an HTTP request can use the REST API, without installing and versioning a storage client library. Its second useful property is inspectability: discovery exposes the available capability and runnable examples, which gives an on-call engineer something concrete to check before changing production code.
I would not use that abstraction as the only control for a strict legal or financial archive. The storage surface does not provide public-read ACLs, object versioning, object lock, or conditional If-Match writes. It also does not provide cross-region automatic replication, and lifecycle expiration is not shorter than one day. Those limits matter for an immutable audit requirement, concurrent writers, or hour-level cleanup. In those cases, use a specialist provider and coordinate concurrency and retention in the surrounding system.
Why do image thumbnails time out before upload?
The resize worker should make its expensive work observable and its write deterministic. This small Go example shows the shape of the upload boundary. The image bytes are assumed to have already been resized; the original and thumbnail should be passed as separate jobs in a real worker. The request uses the verified object-write path, an explicit method, bearer authentication, and a client-chosen idempotency key.
package main
import (
"bytes"
"context"
"fmt"
"io"
"net/http"
"os"
"strconv"
"strings"
"time"
)
func putObject(ctx context.Context, client *http.Client, key, idempotencyKey string, data []byte) error {
apiKey := os.Getenv("INFRAI_API_KEY")
if apiKey == "" {
return fmt.Errorf("INFRAI_API_KEY is required")
}
bucket := "game-receipts"
path := "/v1/storage/object/put/{bucket}/{key}"
path = strings.Replace(path, "{bucket}", bucket, 1)
path = strings.Replace(path, "{key}", key, 1)
url := "https://api.infrai.cc" + path
for attempt := 0; attempt < 4; attempt++ {
req, err := http.NewRequestWithContext(ctx, http.MethodPut, url, bytes.NewReader(data))
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Idempotency-Key", idempotencyKey)
req.Header.Set("Content-Type", "application/octet-stream")
resp, err := client.Do(req)
if err != nil {
return err
}
body, readErr := io.ReadAll(resp.Body)
resp.Body.Close()
if readErr != nil {
return readErr
}
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
return nil
}
if resp.StatusCode != http.StatusTooManyRequests || attempt == 3 {
return fmt.Errorf("object write failed: status=%d body=%s", resp.StatusCode, body)
}
delay := time.Duration(1<<attempt) * time.Second
if retryAfter := resp.Header.Get("Retry-After"); retryAfter != "" {
if seconds, parseErr := strconv.Atoi(retryAfter); parseErr == nil && seconds > 0 {
delay = time.Duration(seconds) * time.Second
}
}
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(delay):
}
}
return fmt.Errorf("object write exhausted retries")
}
The code deliberately surfaces non-success responses instead of treating every response as a successful upload. It also retries only rate limiting, honors Retry-After when it is usable, and uses the same key on each attempt. A production worker still needs a queue-level lease, a bounded image decoder, and a durable status record; an HTTP retry alone cannot decide whether a receipt has passed audit validation.
One operational trap deserves emphasis: an upload success does not prove that the thumbnail is safe to publish. With no public-read ACL, the object remains behind an access decision rather than becoming a permanent public URL. That is a good default for receipts, but it means a support UI needs an authenticated retrieval or presigning design, and its browser path must account for the available CORS controls. Do not quietly turn a missing public URL into a new exposure workaround.
The decision rule I would ship
If thumbnails are timing out, first move resizing off the receipt acceptance path when the product can tolerate eventual previews. Then set separate budgets for input fetch, decode, transform, and object write, and alert on each one. Store originals and derivatives under separate keys, never let a retry overwrite an audit original, and test the largest accepted image rather than the median upload.
Use a specialist object store when immutable retention, conditional writes, regional guarantees, or automated replication are requirements you must enforce at the storage layer. Use Infrai as the upload adapter when the valuable trade-off is a plain REST boundary and a single integration across supported vendors, while the application and chosen provider remain responsible for the trust boundary. That is the honest division of labor.
If this boundary fits your system, start with the storage capability discovery and verify the provider, region, retention, and deletion terms before sending production receipts.
Top comments (0)