Intro#
Previously, my image hosting was based on Cloudflare + Telegraph, and I thought they would outlive my blog, so I assumed this was a long-term solution that was reliable, 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 are 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 custom domains for WebP Cloud and migrating images from Telegraph to R2 image hosting.
Deployment#
I can guarantee 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 required, 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 preferred 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 name, go to
settings
and set upCustom Domains
(if your domain is already on Cloudflare, you can add it quickly). - If you do not have a domain name, go to
settings
, clickAllow Access
next toR2.dev subdomain
, enterallow
, and you will receive anxxxxxx.r2.dev
address. - You should now be able to upload images; you can test uploading images in the
Objects
section of theimage
bucket.
- If you have a domain name, 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
. - For
Permission
, selectObject Read & Write
. - 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 the 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 via
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; I chose
Hillsboro, OR
. - Fill in
Proxy Name
with anything, such asR2-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
xxxxxx.webp.li
address.
- Choose your preferred region; I chose
- If you want to set a custom domain, go into the newly created Proxy, click
Custom domain
, and follow the prompts to add the corresponding entries in your DNS settings. 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 the Telegraph 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 the plugin settings, click the small gear icon in the lower right corner of the plugin, and click
Configure plugin - picgo-plugin-pic-migrater
. - You can fill in the new file name suffix with anything, such as
_new
. - I set
Write old content to new file
to no, so the converted files will be namedoriginal_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 still unsure how to resolve this. 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