Telezon S3 is a storage service compatible with Amazon S3 API that uses Telegram as a storage backend. It allows storing and retrieving files using standard S3 clients.
The easiest way to run Telezon S3 is using Docker Compose:
- Clone the repository
- Copy the environment variables file:
cp .env.example .env
- Configure the variables in the
.env
file - Start the services:
docker-compose up -d
The service will be available at http://localhost:8000
The interactive API documentation is available through Swagger UI. You can access it at:
http://localhost:8000/docs
- Python 3.12+
- Poetry
- Docker and Docker Compose
- A Telegram account or bot
- A Telegram channel
- Clone the repository
- Copy the
.env.example
file to.env
and configure the environment variables:
cp .env.example .env
# Server Configuration
PROJECT_NAME='Telezon S3'
PORT=8000
SECRET_KEY=your_secret_key
# MongoDB Configuration
MONGO_HOST=localhost
MONGO_PORT=27017
MONGO_USER=admin
MONGO_PASSWORD=your_password
DATABASE_NAME=TelezonS3
# Telegram Configuration
BOT_TOKEN=your_bot_token
CID=your_channel_id
TELEGRAM_API_ID=your_api_id
TELEGRAM_API_HASH=your_api_hash
SESSION_STRING=your_session_string
The system allows configuring an initial admin user through environment variables:
INITIAL_ADMIN_USER=admin
INITIAL_ADMIN_PASSWORD=admin
These credentials will be used to automatically create the first admin user in the system during database initialization.
- Install dependencies:
poetry install
- Start the server in development mode:
make dev
- Configure storage using
pyrogram
(Recommended):
make setup_account_storage
- Configure storage using
python-telegram-bot
(Not recommended):
make setup_bot_storage
import boto3
s3 = boto3.client(
's3',
aws_access_key_id='your_access_key_id',
aws_secret_access_key='your_secret_key',
endpoint_url='http://localhost:8000' # Or your production URL
)
# Upload file
s3.upload_file('local_file.txt', 'bucket_name', 'destination_name.txt')
# Download file
s3.download_file('bucket_name', 'destination_name.txt', 'downloaded_file.txt')
The project includes utility scripts for uploading and downloading files:
poetry run python upload_file.py \
--access-key-id your_access_key_id \
--secret-key your_secret_key \
--bucket-name bucket_name \
--input-path local_file.txt \
--output-path destination_name.txt
poetry run python download_file.py \
--access-key-id your_access_key_id \
--secret-key your_secret_key \
--bucket-name bucket_name \
--input-path remote_file.txt \
--output-path local_destination_file.txt
make dev
: Start server in development modemake run
: Start server in production modemake format
: Format code using ruffmake setup_bot_storage
: Set up bot storagemake setup_account_storage
: Set up account storagemake export
: Export dependencies to requirements.txt
- Compatible with Amazon S3 API
- Uses Telegram as storage backend
- Support for basic S3 operations (upload/download)
- Integration with standard S3 clients
Contributions are welcome. Please open an issue to discuss proposed changes.
For high-traffic projects, Telegram's limitations might eventually become a bottleneck that can't be circumvented. In such cases, I'd recommend using actual S3 or another storage solution specifically designed for high-concurrency file serving. This project works great for personal/small deployments, but it's important to acknowledge its limitations for production environments with high demand.
MIT