Full Chinese version: 自建 Cloudflare R2 图床:免费、S3 兼容、全球加速
The core idea#
Writing articles means adding images, and images need a host. Cloudflare R2 is the most hassle-free option I have used: 10GB free storage + millions of reads/writes per month, S3-compatible, custom domain, and global CDN caching.
Why R2#
- Cheap: free tier covers personal usage;
- Compatible: standard S3 API works with PicGo, rclone, etc.;
- Stable: Cloudflare edge network + Cache Rules for fast loading;
- Simple: no server to maintain.
Setup in 5 steps#
- Create a bucket in Cloudflare R2;
- Bind a custom domain (e.g.
r2.your-domain.com) — Cloudflare auto-creates CNAME and certificate; - Create an R2 API Token (Object Read & Write, scoped to the bucket);
- Configure PicGo with the S3 plugin (access key, endpoint
https://<account-id>.r2.cloudflarestorage.com, upload path{year}/{month}/{md5}.{extName}, urlPrefixhttps://r2.your-domain.com); - Install the Obsidian auto-upload plugin pointed at PicGo — paste an image and the link is written back automatically.
Caching#
R2 custom domains do not cache by default; add a Cache Rule matching image extensions with a 30-day edge TTL, so repeat visits hit the edge instead of origin.
Troubleshooting tips#
- Upload failing: check PicGo is running and the token is valid;
- Old image after replacement: purge cache or append
?v=timestamp; - 403 on tests: use a browser User-Agent, Cloudflare blocks bare scripts as bots;
- Data safety: R2 objects persist; if the domain lapses, keep the r2.dev fallback domain active.
Read the full Chinese article for details.








