3 min read

Getting Started with Cloudflare R2: Easy Guide for Image and Video Storage

Getting Started with Cloudflare R2: Easy Guide for Image and Video Storage

I have most of my domains with Cloudflare, and I’m very happy with their service. So, I decided to try their option for storing resources like images and videos, such as showing them in my posts.

I used to use Amazon’s S3, but I wanted to try something new and see how it works.

What is Cloudflare R2?

Cloudflare R2 is a new way to store and serve your images and videos. It lets you keep your files in the Cloudflare network. This means your images and videos will load faster because they’re served from the edge of the network.

How to get started with Cloudflare R2 (Custom Domain)

The first thing you need to do is go to the R2 section on Cloudflare. Then, create a Bucket. A Bucket is like a folder where you can store your files by dragging them in. Once you have created your Bucket, go to the Settings tab.

In the Settings tab, find the section called ‘Public Access’ and enable it (but which option should I choose?, I will tell you in a minute). This lets you access your files from the web (but remember, anyone else can access them too).

You have 2 options: you can enable R2.dev or use your own domain. I will use my own custom domain and call it assets.albertomoral.com, so any image or video I upload to my bucket will have this URL assets.albertomoral.com/name_of_the_asset.png

After a few minutes, your Bucket will be ready, and you can start uploading your files. Drag a new image into the Bucket and click on the image you uploaded. You will see a full URL. If you copy and paste this URL into your browser, you will be able to see the image you uploaded.

That’s it! 🚀