Skip to content

Image Hosting with Cloudflare R2

A guide to building an image hosting platform with Cloudflare R2

Published View as Markdown

Cloudflare R2 is a cloud storage service built on the Amazon S3 API. It lets you store any number of objects and access them over an HTTP API. With Cloudflare R2 we can build an image hosting service for storing and sharing images.

What makes Cloudflare R2 worth a look

  • Store any number of objects
  • S3 API compatible
  • No egress charges
  • 10 GB of free storage

Steps

  1. Create a Cloudflare account
  2. Create an R2 bucket
  3. Configure access permissions
  4. Upload images
  5. Get the image URL

Pricing plans

Feature Free plan Paid plan
Storage 10 GB Unlimited
Egress Free Free
Requests 100,000 per day Unlimited

Reference code

const s3 = new S3Client({
  region: 'auto',
  endpoint: 'https://r2.cloudflare.com',
  credentials: {
    accessKeyId: 'accessKeyId',
    secretAccessKey: 'secretAccessKey',
  },
})
Navigation

Type to search…

↑↓ navigate↵ selectEsc close