Intro#
Previously, my image hosting was based on Cloudflare + Telegraph. I thought they would outlive my blog, so I assumed this was a long-term solution, reliable and easy to use, and most importantly, free.
However, recently the CEO of Telegram was arrested, and South Korea has had conflicts with Telegram due to censorship issues. As a result, the image hosting service of Telegraph can no longer upload new images; old images are still accessible, but it's uncertain when they will cease to function.
Thus, I began searching for a new image hosting solution. My expectations were reliable and easy to use, preferably free. Cloudflare R2 + PicGo + WebP Cloud is such a solution.
This article mainly references this article, and also includes content on WebP Cloud custom domains and migrating images from Telegraph to R2 image hosting.
Deployment#
I can assure you that as of September 2024, my deployment method is effective.
You will need#
- A Cloudflare account with a linked credit card (a prerequisite for enabling R2)
- A domain name (not mandatory, but it looks cooler if you have one)
Now, let's get started...
Enable Cloudflare R2#
- Open the Cloudflare dashboard, select
R2
, where you can see the free quota forR2
, and click to agree to enable it. - Create a new bucket (
Create bucket
)- Enter a name you like, such as
image
. - Choose your desired region, such as
APAC
. - Click
Create bucket
to create it.
- Enter a name you like, such as
- Click on the newly created bucket named
image
.- If you have a domain, go to
settings
, and set upCustom Domains
(if your domain is on Cloudflare, you can add it quickly). - If you don't have a domain, go to
settings
, clickAllow Access
next toR2.dev subdomain
, enterallow
, and you will receive an address likexxxxxx.r2.dev
. - You should now be able to upload images; you can test by uploading images in the
Objects
section of theimage
bucket.
- If you have a domain, go to
- Now click on R2 on the left side of the page, return to
Overview
, and underAccount details
, clickManage R2 API Tokens
underAccount ID
.- Click
Create API token
to create a new API token. - Give it a name, such as
image-R2
. - Select
Object Read & Write
forPermission
. - Under
Specify buckets
, select theimage
bucket you just created. - Click
Create API Token
to create it. - You will receive the information needed for PicGo, including
Access Key ID
,Secret Access Key
, andendpoints
. This will only be displayed once, so please save it.
- Click
- At this point, all operations in the Cloudflare dashboard are complete.
Set up PicGo#
- Download PicGo.
- After installation, click on plugin settings, search for
s3
, find the plugin byWayJam So
, and install it. - Go to the image hosting settings, find
Amazon S3
, and add or modify the default settings.- You can name the image hosting configuration anything, like
r2
. Application Key ID
is yourAccess Key ID
.Application Secret
is yourSecret Access Key
.Bucket Name
is the name of the bucket you set, which isimage
here.Custom Endpoint
is yourendpoints
.Custom Domain
is your setCustom Domains
or thexxxxxx.r2.dev
address assigned by Cloudflare.- Click confirm.
- You can name the image hosting configuration anything, like
- At this point, you should be able to upload photos using
PicGo
.
Use WebP Cloud to proxy your address.#
- Go to the WebP Cloud Dashboard, and log in.
- In the left sidebar under
Price
, you can see the free quota. - In the left sidebar under
Home
, scroll down and clickCreate Proxy
.- Choose your preferred region; here I select
Hillsboro, OR
. - Fill in
Proxy Name
with anything, likeR2-image
. - For
Proxy Origin URL
, enter your setCustom Domains
or thexxxxxx.r2.dev
address assigned by Cloudflare. - Click
Create
to create it. - At this point, you will be assigned an address like
xxxxxx.webp.li
.
- Choose your preferred region; here I select
- If you want to set a custom domain, go to the newly created Proxy, click
Custom domain
, and follow the prompts to add the corresponding entries in your DNS resolution. After a moment, you will be able to activate your custom domain inCustom domain
. - Next, you need to change the
Custom Domain
inPicGo
to the custom domain you set inWebP Cloud
or thexxxxxx.webp.li
address assigned byWebP Cloud
.
Migration#
I have a large number of images stored in Telegraph's image hosting, and I want to migrate all of them to R2. The PicGo plugin pic-migrater
is a good choice, developed by Molunerfinn
.
- After downloading the plugin, click on plugin settings, click the small gear in the lower right corner of the plugin, and click
Configure plugin - picgo-plugin-pic-migrater
. - Enter any suffix for the new file name, such as
_new
. - I set
Write old content to new file
to no, so the converted files will be namedsource_filename_new.md
, making it easy for me to check these files.
However, for some markdown files, pic-migrater
may encounter issues migrating, and I am not sure how to resolve it. My approach is to handle the orphaned files one by one manually.
Outro#
That's all for now.
This article is synchronized and updated to xLog by Mix Space. The original link is https://xxu.do/posts/geek/Cloudflare-R2%2BPicGo%2BWebP-Cloud