This guide explains how to set up FilesLink with FastTelethon to support downloading files larger than 20MB (up to 2GB).
- Telegram Bot Token (from @BotFather)
- Telegram API Credentials (API_ID and API_HASH from https://my.telegram.org/apps)
- Storage Channel (a private Telegram channel or chat to store files)
- Docker and Docker Compose installed
- Go to https://my.telegram.org/apps
- Log in with your phone number
- Create a new application (if you don't have one)
- Note down your
api_id(numeric) andapi_hash(string)
- Open Telegram and create a new private channel
- Note the channel username (e.g.,
@my_files_storage) or ID - Make sure your user account is an admin of this channel
Create or update your .env file:
# Existing bot configuration
BOT_TOKEN=your_bot_token_here
STORAGE_CHANNEL_ID=@your_channel_username_or_id
# FastTelethon configuration (NEW)
TELEGRAM_API_ID=your_api_id
TELEGRAM_API_HASH=your_api_hash
TELEGRAM_PHONE=+1234567890 # Your phone number with country code
STORAGE_CHANNEL_ID=@your_channel_username_or_id
# Service URLs
FASTTELETHON_URL=http://fasttelethon:8001
APP_FILE_DOMAIN=https://yourdomain.com/filesNo manual authorization needed! The service will handle it automatically through a web interface.
# Build all services
docker-compose build
# Start services
docker-compose up -d
# Check logs
docker-compose logs -f fasttelethonThe FastTelethon service will automatically send a verification code to your phone number.
- Open your browser: Go to http://localhost:8001/auth
- Enter verification code: Check your Telegram app for the code
- Enter 2FA password (if you have 2FA enabled)
- Done! The service is now authorized and ready to use
The session will be saved automatically and persists across restarts.
# Build all services
docker-compose build
# Start services
docker-compose up -d
# Check logs
docker-compose logs -f- Send a file larger than 20MB to your bot
- The bot will forward it to your storage channel
- You'll receive a download link
- When someone clicks the link:
- Files <20MB: Downloaded directly via Bot API
- Files ≥20MB: Downloaded via FastTelethon (fast parallel download)
If your session expires or you need to re-authorize:
- Stop the service:
docker-compose down - Delete the session file:
rm python_service/sessions/*.session - Start the service:
docker-compose up -d - Visit http://localhost:8001/auth again
User → Bot (teloxide)
↓
File received
↓
[Size Check]
↓
<20MB? → Upload via Bot API → Storage Channel
↓
≥20MB? → Forward to FastTelethon → Upload via MTProto → Storage Channel
(fast, parallel)
Download:
User → HTTP Server (Rust/Axum)
↓
[Try Bot API]
↓
Too large error?
↓
Proxy to FastTelethon → Download via MTProto → Stream to User
(fast, parallel)
GET /health- Health checkPOST /upload- Upload large fileGET /download/{channel_id}/{message_id}- Download large fileGET /file-info/{channel_id}/{message_id}- Get file metadata
GET /files/{unique_id}_{filename}- Download file (auto-proxies large files)GET /files- List all files (if enabled)
| Method | File Size Limit | Speed | Notes |
|---|---|---|---|
| Bot API | 20MB | 1-3 MB/s | Limited by Telegram's bot API |
| FastTelethon | 2GB | 10-30 MB/s | Parallel download, MTProto client |
If the session expires or has issues:
# Delete old session
rm python_service/sessions/fasttelethon_session.session
# Re-authorize
cd python_service
python authorize.pyCheck logs:
docker-compose logs fasttelethonCommon issues:
- Session file not found → Re-authorize
- API credentials invalid → Check
.envfile - Channel not accessible → Make sure your user is admin
-
Check if FastTelethon service is running:
curl http://localhost:8001/health
-
Check if message exists in channel:
curl http://localhost:8001/file-info/{channel_id}/{message_id} -
Check Rust server logs:
docker-compose logs app
- Keep
.sessionfiles secure - They grant full access to your Telegram account - Use environment variables - Don't commit credentials to git
- Restrict channel access - Make storage channels private
- Use HTTPS - In production, serve files over HTTPS
# Pull latest changes
git pull
# Rebuild containers
docker-compose build
# Restart services
docker-compose up -d# View all logs
docker-compose logs -f
# View specific service
docker-compose logs -f fasttelethon
docker-compose logs -f app
# Check service status
docker-compose psFor issues, check:
- Docker logs:
docker-compose logs - Session file exists:
ls python_service/sessions/ - Environment variables set:
cat .env - FastTelethon health:
curl http://localhost:8001/health