Free Image Hosting Setup Tutorial Based on Cloudflare Pages and Telegram#
type: article
status: published
date: 2024/10/17
slug: tuiljni
summary: Free Image Hosting Setup Tutorial Based on Cloudflare Pages and Telegram
tags: GitHub, image hosting, tools
category: tutorial
Project Address https://github.com/MarSeventh/CloudFlare-ImgBed#
1. Introduction#
1. Open Source#
- Frontend is open source (can be modified and packaged for use)
2. Cool Effects#
- Smooth and silky transition animations~
- Uploading files creates a breathing light effect
3. User-Friendly Uploading#
- Supports most common images, videos, GIFs, etc.
- Supports multiple upload methods (drag and drop, paste)
- Paste upload supports files and URLs
- Supports batch uploads (no limit on the number of files selected at once, but to ensure stability, a maximum of 10 files can be uploaded simultaneously)
- Displays real-time upload progress
- Images do not need to be manually clicked after uploading; they can be directly displayed on the management page
- Oversized images are compressed on the frontend to enhance upload stability and loading performance
- Supports custom compression quality, with options to enable frontend and backend compression
4. Diverse Copying Options#
- Supports full copy and individual copy (full copy means copying all links concatenated by line breaks)
- Supports copying in Markdown, HTML, BBCode, and raw link formats
- Intuitively displays links in four formats after upload completion
5. Supports Authentication and Anti-Abuse Measures#
- Supports Web and API upload authentication (thanks to hl128k)
- Supports access domain restrictions (thanks to hl128k)
- Supports upload IP statistics
6. Supports Page Customization#
- Page background supports various modes such as single image, custom multi-image carousel, Bing random image carousel, etc.
- Customizable image hosting name and logo
- Customizable website title and icon
7. Some Small Features#
- Supports random image API, which randomly returns an image from the image hosting
8. All Features of the Original Version#
Unlimited image storage; you can upload an unlimited number of images
No need to purchase a server; hosted on Cloudflare's network, completely free as long as usage does not exceed Cloudflare's free quota
No need to purchase a domain name; you can use the free subdomain
*.pages.dev
provided by Cloudflare Pages, and it also supports binding custom domain namesSupports image review API, which can be enabled as needed; once enabled, inappropriate images will be automatically blocked and will not load
Supports backend image management, allowing online preview of uploaded images, adding whitelists, blacklists, and other operations
2. Deployment#
1. Create a Telegram Bot to Obtain TG_BOT_TOKEN
#
-
Send
/newbot
to @BotFather and follow the prompts to enter the bot's note, username, and other information. Successfully created, the red part shown in the image isTG_BOT_TOKEN
.Create a Telegram Channel to Obtain
TG_CHAT_ID
#Create a new channel and add the bot to the channel as shown in the image below.
Select the Channel You Just Created and Grant the Bot Admin Permissions#
Forward a Message from the Newly Created Channel to @VersaToolsBot to Obtain TG_CHAT_ID
(Channel ID)#
Deploy on Cloudflare#
Leveraging CF's powerful capabilities, you can deploy this project in just a few simple steps and have your own image hosting.
- Open the Cloudflare Dashboard, go to the Pages management page, select to create a project, and choose
Connect to Git Provider
- Follow the prompts on the page to enter the project name, select the git repository to connect, and click
Deploy Site
- Add the previously obtained
TG_BOT_TOKEN
andTG_CHAT_ID
to the environment variables, with corresponding environment variable names asTG_BOT_TOKEN
andTG_CHAT_ID
- Bind KV Database:
-
Create a new KV database
-
Go to the project's
Settings
>Functions
>KV Namespace Binding
>Edit Binding
>Variable Name
, fill inimg_url
, and select the KV namespace you just created
-
Retry Deployment
, and the project will be ready for use.