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 bucketto 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
settingsand 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 Accessnext toR2.dev subdomain, enterallow, and you will receive anxxxxxx.r2.devaddress. - You should now be able to upload images; you can test uploading images in the
Objectssection of theimagebucket.
- 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 TokensunderAccount ID.- Click
Create API tokento create a new API token. - Give it a name, such as
image-R2. - For
Permission, selectObject Read & Write. - 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 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 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 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 Namewith anything, such asR2-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
xxxxxx.webp.liaddress.
- 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 DomaininPicGoto the custom domain you set inWebP Cloudor thexxxxxx.webp.liaddress 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 fileto 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