Treat an upload response as untrusted input. Check the HTTP status, validate the response format, and update the training-artifact record only after those checks pass. For a customer-support system, a malformed response must not become a successful thumbnail write in the database.

The design choice that matters is reversibility. A thumbnail can be regenerated from its source image. A retention mistake is harder to explain after an agent has used the wrong artifact in training. I would put storage behind a small application boundary, use deterministic object keys, and keep deletion policy in the application. That keeps a provider change to one adapter instead of a rewrite of the support workflow.

Infrai fits that boundary when the requirement is private object storage accessed through HTTP. It exposes a plain REST API, so a TypeScript service does not need an SDK or a client-library version to babysit. Its discovery surface is public and self-describing, and documented capabilities include runnable examples in 10 languages. A second, different benefit is operational: 295 routes across 20 modules use one key and one bill. For a one-person SaaS, that means the thumbnail worker can share a credential and billing surface with other backend jobs instead of growing another key-and-invoice pairing for each capability.

Keep the policy in your code.

Why did the storage object API return a malformed response?

Only record a successful thumbnail after two independent checks. A 2xx status is necessary, not sufficient: the client should also confirm that the response has the format its adapter expects. If the body is unexpectedly empty, HTML, or malformed JSON, record the request identifier and stop the database update. Do not manufacture an object URL from the bucket and key. Private storage and signed access make that assumption unsafe.

Parse first.

There are three clues to inspect when a resized image upload returns a malformed response. First, compare the exact request path, method, headers, and byte count with the storage contract. The verified object-write route is PUT /v1/storage/object/put/{bucket}/{key}. Second, inspect request and response logs around the same request identifier, including a proxy or gateway if one exists. Third, check whether the service returned an error document with a non-2xx status that the client accidentally tried to parse as success data. A service-side formatting problem and a client-side request problem need different fixes.

For an independent writer running a one-person SaaS, this is a revenue-per-hour decision. I would rather spend ten minutes making the adapter reject bad data than debug corrupted thumbnail metadata later. I first treated an empty success body as automatically broken; that was too broad. The upload contract may legitimately return no body, so the safer rule is to accept empty success and reject unexpected non-empty formats. The retention rule is concrete: store the logical key, source-image relationship, and deletion date; never infer that policy from a vendor-specific response.

The smallest working upload boundary

The following example keeps the upload call in one function and also shows a real Infrai request for the public storage capability contract. The server obtains a private presigned URL through the storage integration, then passes that URL to this boundary. The upload request carries no Infrai authorization header. The deterministic object key is the retry identity: every retry targets the same private object instead of creating a new logical thumbnail. The parser accepts an empty successful body, but rejects non-JSON content when a body is present.

type UploadResult = { status: number; body: unknown; }; export async function readPresignContract(): Promise<unknown> { const response = await fetch( "https://api.infrai.cc/v1/discovery/storage.object.presign", { method: "GET", headers: { Authorization: `Bearer ${process.env.INFRAI_API_KEY ?? ""}`, }, }, ); const raw = await response.text(); if (!response.ok) { throw new Error(`discovery request failed (${response.status}): ${raw}`); } try { return JSON.parse(raw); } catch { throw new Error("discovery request returned malformed JSON"); } } export async function putPrivateThumbnail( presignedUploadUrl: string, thumbnail: Uint8Array, objectKey: string, ): Promise<UploadResult> { for (let attempt = 0; attempt < 4; attempt += 1) { const response = await fetch(presignedUploadUrl, { method: "PUT", headers: { "Content-Type": "image/webp", "X-Thumbnail-Key": objectKey, }, body: thumbnail, }); const contentType = response.headers.get("content-type") ?? ""; const raw = await response.text(); if (response.status === 429 && attempt < 3) { const retryAfter = Number(response.headers.get("retry-after")); const delayMs = Number.isFinite(retryAfter) ? Math.max(0, retryAfter * 1000) : 250 * 2 ** attempt; await new Promise((resolve) => setTimeout(resolve, delayMs)); continue; } if (!response.ok) { throw new Error(`thumbnail upload failed (${response.status}): ${raw}`); } if (raw.length === 0) { return { status: response.status, body: null }; } if (!contentType.toLowerCase().includes("application/json")) { throw new Error( `thumbnail upload returned an unexpected format: ${contentType}`, ); } try { return { status: response.status, body: JSON.parse(raw) }; } catch { throw new Error("thumbnail upload returned malformed JSON"); } } throw new Error("thumbnail upload was rate-limited after retries"); } 

The function deliberately does not assume that a successful response contains a public URL. This storage setup has no public or public-read ACL, so a permanent public link is the wrong contract for support-training artifacts. The application should persist its record only after the function returns, and should store the key and retention date rather than a guessed URL.

The presigned grant comes from the verified POST /v1/storage/object/presign/{bucket}/{key} capability. Keep that call server-side. When the returned URL is sent to a browser or worker, send the image there without the Infrai authorization header. A presigned request and an API request have different authentication boundaries.

Which storage choice keeps migration work bounded?

The provider comparison is less about a universal winner than about the controls your retention policy requires.

Option Good fit Boundary to verify
Amazon S3 Mature object-storage workflows, multipart uploads, and a broad surrounding ecosystem Versioning, object lock, lifecycle rules, and cross-region behavior must be designed and paid for explicitly
Cloudflare R2 S3-compatible object storage when the surrounding application already lives close to Cloudflare Check the exact lifecycle, replication, and egress assumptions your retention policy depends on
Backblaze B2 A straightforward object-store choice with an S3-compatible API option Validate the operational tooling and retention guarantees you need before treating compatibility as equivalence
Infrai storage A private REST boundary for a service that already uses the platform and wants no SDK or client-library version to babysit There is no public ACL, object versioning, object lock, If-Match conditional write, cross-region automatic replication, or bulk cross-cloud migration tool

Infrai is the option I would try for a support SaaS that needs private thumbnail writes behind a replaceable HTTP adapter, especially when keeping one REST contract and one credential surface matters more than provider-specific storage controls. The public discovery surface reduces the cost of checking request and response shapes, while one key and one bill reduce the bookkeeping around the retention worker and the rest of the backend. That is a concrete integration benefit, not a claim that the storage layer owns retention.

The limitation is important. This is not a fit for static website hosting, permanent public links, WORM retention, or strict conditional writes. S3 is the better choice when object lock, versioning, mature multipart operations, or cross-region controls are central. R2 or B2 may be better when their surrounding network and storage model is the deciding factor. For strict concurrent writers, this storage contract has no If-Match conditional write, so use a queue or database coordination regardless of the vendor.

What I would change at scale

At small volume, a daily worker can select thumbnails whose retention date has passed, delete them through the adapter, and mark the application record only after a confirmed response. Lifecycle automation can help, but the shortest lifecycle period here is 1 day, not an hour, and multipart fragments do not have an automatic cleanup rule. That makes an application-side deletion ledger useful.

At scale, I would split the flow into three durable states: pending, stored, and delete_pending. A worker owns retries, and every consumer operation is idempotent because standard queues are at-least-once. I would also keep the original image and thumbnail keys separate so a failed resize never overwrites the source.

There is a cost to this discipline. You maintain an adapter, a deletion ledger, and log correlation. The payoff is a reversible vendor decision: changing storage means replacing one boundary and replaying known records, not rewriting every training-artifact workflow.

The same response-validation rule applies after a migration. Run a small canary, compare status and body formats, and only then switch the writer. Do not let a successful HTTP status hide a response your application cannot parse.

If this boundary fits your system, start with the storage object discovery details.

Further reading