图片转链接

How to Upload Images to Cloudflare R2 and Get a Public URL (2026 Guide)

# How to Upload Images to Cloudflare R2 and Get a Public URL If you have ever wanted to drop a screenshot into a forum post, embed a product photo on your Shopify page, or share a PDF in a Discord channel without attaching the file — you have run into the same problem: **where do I host this so I can get a stable, fast URL?** **Cloudflare R2** is one of the best answers in 2026, because it offers zero egress fees and S3-compatible APIs. This guide walks you through the entire flow, from creating a bucket to sharing your first direct URL. ## Why R2 over Imgur / ImgBB / S3? - **Free egress** — R2 does not charge for data transferred to users, which is the single biggest cost on AWS S3. - **Global edge cache** — files cached on Cloudflare's network feel instant almost everywhere. - **S3-compatible API** — every S3 SDK, CLI, and tutorial on the internet works. ## Three ways to upload 1. **The fastest way** — use a hosted service like [imagetourls.com](https://imagetourls.com). You drag, drop, and copy the URL. No AWS account, no API key, no console. 2. **The DIY way** — create an R2 bucket in the Cloudflare dashboard, generate an access key, and use the `aws s3 cp` CLI with the R2 endpoint. 3. **The developer way** — use the AWS SDK in your app, point it at `https://<account>.r2.cloudflarestorage.com`, and stream uploads from the browser. ## What formats work? R2 stores any binary blob. Common use cases on imagetourls.com: - Images: PNG, JPG, WebP, AVIF, GIF, SVG - Video: MP4, WebM, MOV (up to multi-GB) - Documents: PDF, DOCX, XLSX - Audio: MP3, WAV, OGG ## Tips for a clean public URL - Use a custom domain (e.g. `cdn.yoursite.com`) bound to your R2 bucket — it looks more professional than the default R2 hostname. - Set `Cache-Control: public, max-age=31536000, immutable` on files you will never change. - For frequently updated files, append a version query string: `?v=2`. ## Wrapping up If you just want a URL without setting up an entire R2 account, [imagetourls.com](https://imagetourls.com) handles the bucket, CDN, and custom-domain wiring for you. The whole upload-to-share loop takes about 5 seconds — and your first 1 GB of storage is free.

返回博客列表