Reference guide · images · Published 2026-08-16 · 3 min read

Object storage vs a database for image files

Compare object storage and a database for website images, and decide when files belong in the browser addressable store vs the DB.

Every website with uploads makes a storage decision early, and the common mistake is treating the database as a place to hold image bytes. Images and other browser-delivered files have different needs from the rows that describe them, and modern hosting gives you a separate store designed for exactly that job.

Where image files belong in the stack

An image is downloaded directly by the browser; a database row is queried by your application and rarely served byte-for-byte to a visitor. That difference drives the placement:

The real cost of image blobs in a database

Storing a 2 MB image as a BLOB works on a small site. It fails as you scale for concrete reasons:

When a database is the right home

There are legitimate uses for bytes in the database. Store the file in the database when the blob is small, not browser-addressable, or must be atomic with its row: an encrypted document that must never be served publicly, a private original before combining, or a small profile avatar on a low-traffic app. In those cases the atomicity and one-server simplicity outweigh the scale cost. The moment the asset is a large photo a visitor loads, it belongs in object storage.

The split that scales

The standard pattern is: object storage holds the file, a CDN caches it at the edge, and the database holds only the reference plus metadata.

ConcernObject storageDatabase BLOB
Served directly to browserYes, via URLNo, via app
Edge/CDN cachingNativeHard
Backup/restore weightBucket separateGrows with every image
Metadata queryUse DB for itUse DB for it
Best forReal photos, derivativesTiny/private blobs

The derivative pipeline lives at the edge in the image CDN article, and serving many small files at scale is covered in the thumbnail guide. If you ever move the media store between systems, the large database export guide explains how to keep the metadata side separate from the file side.

Need a website built, fixed, optimised, migrated or replaced?

This technical resource is written by CSMBAC, a small design and development studio. If you would rather hand the problem to a professional, the website service page explains how we build enquiry-ready websites.

Explore website services