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 bucketto 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 Accessnext 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
Objectssection of theimagebucket.
- 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 TokensunderAccount ID.- Click
Create API tokento create a new API token. - Give it a name, such as
image-R2. - Select
Object Read & WriteforPermission. - Under
Specify buckets, select theimagebucket you just created. - Click
Create API Tokento 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 IDis yourAccess Key ID.Application Secretis yourSecret Access Key.Bucket Nameis the name of the bucket you set, which isimagehere.Custom Endpointis yourendpoints.Custom Domainis your setCustom Domainsor thexxxxxx.r2.devaddress 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 Namewith anything, likeR2-image. - For
Proxy Origin URL, enter your setCustom Domainsor thexxxxxx.r2.devaddress assigned by Cloudflare. - Click
Createto 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 DomaininPicGoto the custom domain you set inWebP Cloudor thexxxxxx.webp.liaddress 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 fileto 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