This project is a serverless file upload center built on Cloudflare Workers that leverages Telegram's Bot API for free file storage and sharing. It allows users to upload files, which are then sent to a Telegram chat via a bot, and provides a user-friendly interface to manage and download the uploaded files. This guide will walk you through setting up the project directly using the Cloudflare Workers dashboard (no Wrangler CLI required).
- Prerequisites
- Step 1: Create a Cloudflare Workers Account
- Step 2: Create a Telegram Bot
- Step 3: Get Your Telegram Chat ID
- Step 4: Create a Cloudflare Worker
- Step 5: Bind a KV Namespace
- Step 6: Deploy and Test
- A Cloudflare account.
- A Telegram account.
- Basic knowledge of using web interfaces.
- Go to the Cloudflare Workers website.
- Click on Sign Up and create a new account or log in if you already have one.
- Once logged in, navigate to the Workers section from the dashboard.
- Open Telegram and search for the BotFather (Telegram's official bot for creating bots).
- Start a chat with BotFather and use the
/newbot
command. - Follow the instructions:
- Choose a name for your bot (e.g.,
MyUploadBot
). - Choose a username for your bot (must end with
bot
, e.g.,MyUploadBot_bot
).
- Choose a name for your bot (e.g.,
- Once the bot is created, BotFather will provide you with a bot token. Save this token securely.
- Start a chat with your newly created bot on Telegram.
- Send any message to the bot (e.g.,
/start
). - Open the following URL in your browser (replace
YOUR_BOT_TOKEN
with your actual bot token):https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates
- Look for the
chat
object in the JSON response. Theid
field is your Chat ID. Save this ID.
- In the Cloudflare Workers dashboard, click Create a Service.
- Name your worker (e.g.,
telegram-upload-center
). - Choose the HTTP handler template.
- Click Create Service.
- replace the worker content with workers.js
- replace with your token and chat id in first few lines 7 . deploy
- In your worker's dashboard, go to the KV section.
- Click Create a Namespace and name it (e.g.,
UPLOAD_STORE
). - Once created, go back to your worker's Settings > Variables.
- Under KV Namespace Bindings, click Edit Variables.
- Add a new binding:
- Variable name:
UPLOAD_STORE
- KV namespace: Select the namespace you just created.
- Variable name:
- Visit your worker's URL (provided in the dashboard) to access the upload center.
- Test the functionality:
- Upload a file.
- View the list of uploaded files.
- Download or delete files.
Star the repo if you find it useful! ⭐