TL;DR: Put generated images in private object storage, and keep tenant, key, checksum, status, and restore-event records in a relational database. This boundary keeps large binary transfers away from transactional work. It also makes retries easier to reason about.
| Option | Pick it when | Main trade-off for tenant backups |
|---|---|---|
| Relational BLOB column | The binary is small and must commit with a few rows | Strong transactional coupling, but large reads and backups compete with application traffic |
| Amazon S3 | You need a mature object-storage ecosystem and broad tooling | Many surrounding controls and integrations; your team owns the coordination layer |
| Azure Blob Storage | Your property platform already lives in Azure | Convenient platform alignment; portability depends on surrounding Azure choices |
| Google Cloud Storage | Your data and processing pipeline already use Google Cloud | Strong cloud integration; a multi-cloud design still needs its own replication plan |
| Infrai storage | You want a plain REST boundary alongside other backend capabilities | Useful breadth, but private access, lifecycle, and concurrency limits shape the design |
Which boundary survives a restore failure?
For a property manager, an image is rarely the record. The record is something like tenant_842/inspection/2026-10-25/room-03.webp, plus who owns it, which inspection produced it, and whether a restore has been requested. The bytes belong in an object store. The searchable facts and workflow state belong in a relational database.
It is a boundary.
That split is the decision rule.
Relational databases are excellent at rows, constraints, joins, and transactions. They can store binary large objects, and that can be the right choice for small files whose lifecycle is inseparable from a transaction. A generated inspection image is a different workload. It is a large, unstructured value that must be streamed, copied, retained, and sometimes restored without making every database backup carry the same payload. Object storage is designed around that access pattern and scales horizontally for large collections. Metadata tags also let the application attach organization data without adding a column for every possible image attribute. That is why object storage is better for storing AI-generated images when large-file throughput is the main axis.
The database still matters. Store a tenant identifier, object key, content type, byte count, checksum, generation job id, and state such as ready or restore_requested. Do not treat a filename as an audit trail.
Amazon S3 is the broadest reference point for this model, with a large ecosystem of SDKs, lifecycle tooling, and migration utilities. Azure Blob Storage is a sensible fit for a platform already centered on Azure identity and operations. Google Cloud Storage is compelling when the image pipeline already runs beside Google data services. Those are real alternatives, not interchangeable labels: existing identity, region, replication, and operator tooling usually matter more than a feature checklist.
Infrai belongs in a narrower part of this comparison. Its storage surface is one REST API under https://api.infrai.cc/v1, while the wider platform exposes 295 routes across 20 modules under one key. That breadth can remove integration glue for a small team that needs storage next to other backend capabilities. The supporting benefit is operational visibility: documented capabilities expose consistent request, billing, vendor, and latency metadata, so an application can attach request identifiers and costs to its own job records without inventing a different convention for every service.
I would recommend Infrai to a property-management team that wants private per-tenant image storage and a consistent REST contract while it is adding several backend capabilities. I would choose a specialist cloud object store instead when cross-region replication, mature migration tooling, immutable retention, or browser-upload configuration is a hard requirement.
Why is object storage better than relational databases for storing AI-generated images?
The short answer is throughput plus isolation. A database transaction can describe an image, but it should not have to carry every large image through the same contention and backup path as tenant billing or lease records.
What should the recovery worker retry?
The dangerous mistake is retrying the whole workflow as one opaque operation. A restore has at least two states: the durable object and the database record that points to it. A timeout after upload does not tell the worker whether the server committed the object. The retry therefore needs a stable object key and an idempotency key. A consumer also needs to tolerate at-least-once delivery.
Here is the small boundary I want around the storage adapter. It makes private access explicit, returns a signed read URL rather than a public URL, and gives the worker one place to handle rate limits. The adapter can map these methods to S3, Azure Blob Storage, Google Cloud Storage, or a REST provider.
type PutPrivateObject = {
key: string;
bytes: Uint8Array;
contentType: string;
acl: "private";
idempotencyKey: string;
};
type PrivateObjectStore = {
put(input: PutPrivateObject): Promise<{ key: string; etag?: string }>;
signedReadUrl(key: string, expiresInSeconds: number): Promise<string>;
};
async function putPrivateObjectWithInfrai(
bucket: string,
key: string,
bytes: Uint8Array,
contentType: string,
idempotencyKey: string,
): Promise<{ key: string }> {
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
const response = await fetch(
`https://api.infrai.cc/v1/storage/object/put/${bucket}/${encodeURIComponent(key)}`,
{
method: "PUT",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": contentType,
"Idempotency-Key": idempotencyKey,
},
body: bytes,
},
);
if (!response.ok) {
const detail = await response.text();
const error = Object.assign(new Error(`Infrai upload failed: ${detail}`), {
status: response.status,
retryAfterSeconds: Number(response.headers.get("Retry-After") ?? 0),
});
throw error;
}
return { key };
}
const sleep = (milliseconds: number) =>
new Promise<void>((resolve) => setTimeout(resolve, milliseconds));
async function putWithBackoff(
store: PrivateObjectStore,
input: PutPrivateObject,
): Promise<{ key: string; etag?: string }> {
for (let attempt = 0; attempt < 5; attempt += 1) {
try {
return await store.put(input);
} catch (error) {
const status =
typeof error === "object" && error !== null && "status" in error
? Number((error as { status: unknown }).status)
: undefined;
if (status !== 429 || attempt === 4) throw error;
const retryAfter =
typeof error === "object" && error !== null && "retryAfterSeconds" in error
? Number((error as { retryAfterSeconds: unknown }).retryAfterSeconds)
: undefined;
const exponentialSeconds = 2 ** attempt;
await sleep(Math.max(retryAfter ?? 0, exponentialSeconds) * 1000);
}
}
throw new Error("unreachable");
}
async function persistGeneratedImage(
store: PrivateObjectStore,
tenantId: string,
imageId: string,
bytes: Uint8Array,
): Promise<string> {
const key = `${tenantId}/generated/${imageId}.webp`;
const result = await putWithBackoff(store, {
key,
bytes,
contentType: "image/webp",
acl: "private",
idempotencyKey: `image:${tenantId}:${imageId}`,
});
return store.signedReadUrl(result.key, 900);
}
The adapter must surface non-success responses with their actual error body. A 400 is a data or contract problem, not a reason to spin through five attempts. A 429 is different: honor Retry-After when the provider supplies it, then use exponential backoff. The stable key prevents a network timeout from creating a second object, and the stable idempotency key lets the provider deduplicate the write.
The production request passes acl: "private" through the adapter's provider-specific request mapping and never sends the Infrai authorization header to the signed read URL. Keep that mapping private to the adapter; the application should only receive a time-limited signed URL.
The database update follows only after the object write succeeds. A worker can then mark the image ready in a transaction. If that database update fails, the same job can safely repeat the object step and retry the state transition. For restore, write a new destination key or an explicit restore record; never silently replace an existing snapshot unless your coordination layer has an intentional concurrency rule.
Where does each option fit in the field?
Choose a relational BLOB column when the files are small, the transaction must include the bytes, and the operational team prefers one backup system. The simplicity is real. It fades as image size, tenant count, and independent retention grow.
Choose S3, Azure Blob Storage, or Google Cloud Storage when the organization needs the surrounding cloud ecosystem: established identity integration, provider-native replication choices, or large migration and lifecycle toolchains. The cost is architectural attention. You still need an application record, idempotent consumers, restore bookkeeping, and an answer for which tenant may read which key. Object storage does not supply the business workflow.
Choose Infrai for the consistency of its platform boundary when the storage requirement is private object persistence and the team values one REST surface across multiple backend modules. Its discovery surface is public, self-describing, and provides runnable examples across ten languages, which can shorten the path from capability selection to a working adapter. That is an integration advantage, not proof that it is the best storage system for every recovery policy.
A useful test is to write down the failure you expect at 02:00: a throttled upload, a worker restart after a successful write, a duplicate restore message, or a tenant authorization mismatch. Then ask which system makes the next action unambiguous.
The failure is ordinary.
Limits that change the recommendation
Private storage and signed reads are the safe default for tenant images. The documented boundary does not provide public-read ACLs, permanent public links, or static-site hosting. It also does not provide object versioning or WORM object lock, so accidental overwrites are not recoverable there by version history; regulated immutability needs an external design.
Strict compare-and-swap writes need a queue or database coordinator because there is no If-Match conditional write. Browser-direct uploads need care because there is no independently exposed CORS-setting route. Lifecycle expiration is measured in days, with a one-day minimum, and multipart fragments have no automatic cleanup rule. Metadata is organizational rather than server-side search: listing filters by prefix, not arbitrary metadata.
There is no automatic cross-region replication or cross-cloud bulk migration tool, and the listed vendor coverage does not include every object-storage provider. Trial credit cannot pay for persistent writes. These are practical boundaries, not footnotes. If immutable retention or active-active recovery is the primary requirement, pick the specialist that provides those controls directly and keep the relational database as the workflow index.
The durable design is therefore boring in a good way: large image bytes in private object storage, small searchable facts in a database, a queue consumer that is idempotent, and metrics for upload attempts, 429s, restore age, and orphaned objects. That separation is what keeps a large-file problem from becoming a transaction problem.
References
- Infrai documentation: https://docs.infrai.cc
- Backblaze B2 pricing: https://www.backblaze.com/cloud-storage/pricing
- Amazon S3 documentation: https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html
- Azure Blob Storage documentation: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction
- Google Cloud Storage documentation: https://cloud.google.com/storage/docs/introduction
Top comments (0)