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
- Create a Cloudflare account
- Create an R2 bucket
- Configure access permissions
- Upload images
- 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',
},
})