Can DynamoDB store images?

Yes, but only small ones. DynamoDB can store images as base64-encoded Binary (B) attributes, provided the whole item stays under the 400 KB limit. AWS recommends storing larger images in Amazon S3 and keeping just the object metadata and an S3 reference in DynamoDB, since 400 KB is too small for most media files.

How small-image storage works

Encode the image as base64 and store it in a Binary attribute. DynamoDB measures the raw byte length toward the 400 KB item cap, so a thumbnail or icon fits; a full photo usually does not.

For anything larger than 400 KB:

  1. Upload the image to Amazon S3.
  2. Store its S3 key, size, content type, and other metadata in DynamoDB.
  3. Read the metadata from DynamoDB, then fetch the object from S3.

Note that DynamoDB and S3 do not share transactions, so your app must clean up orphaned objects on failure.

Go deeper

See max item size and measure items with the item size calculator. Download DynoTable to inspect binary attributes.

不必透過主控台就能操作 DynamoDB

DynoTable 是一款快速的 DynamoDB 桌面用戶端 — 瀏覽表格、執行 SQL 風格的查詢,並在本機編輯項目。