Skip to content

Telezon S3 is a storage service that implements Amazon S3-compatible API using Telegram as the storage backend. It allows you to store and retrieve files using standard S3 clients while leveraging Telegram's infrastructure for actual file storage.

License

Notifications You must be signed in to change notification settings

luiscib3r/Telezon-S3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telezon S3

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.

Docker Deployment

The easiest way to run Telezon S3 is using Docker Compose:

  1. Clone the repository
  2. Copy the environment variables file:
cp .env.example .env
  1. Configure the variables in the .env file
  2. Start the services:
docker-compose up -d

The service will be available at http://localhost:8000

API Documentation

The interactive API documentation is available through Swagger UI. You can access it at:

http://localhost:8000/docs

Development Requirements

  • Python 3.12+
  • Poetry
  • Docker and Docker Compose
  • A Telegram account or bot
  • A Telegram channel

Configuration

  1. Clone the repository
  2. Copy the .env.example file to .env and configure the environment variables:
cp .env.example .env

Important Environment Variables

# 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

Initial Admin User

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.

Development

  1. Install dependencies:
poetry install
  1. Start the server in development mode:
make dev

Telegram Bot and Channel Setup

  1. Configure storage using pyrogram (Recommended):
make setup_account_storage
  1. Configure storage using python-telegram-bot (Not recommended):
make setup_bot_storage

Usage

Python Client (boto3)

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')

Quick Upload and Download Script

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

Available Make Commands

  • make dev: Start server in development mode
  • make run: Start server in production mode
  • make format: Format code using ruff
  • make setup_bot_storage: Set up bot storage
  • make setup_account_storage: Set up account storage
  • make export: Export dependencies to requirements.txt

Features

  • Compatible with Amazon S3 API
  • Uses Telegram as storage backend
  • Support for basic S3 operations (upload/download)
  • Integration with standard S3 clients

Contributing

Contributions are welcome. Please open an issue to discuss proposed changes.

Important note about scalability:

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.

License

MIT

About

Telezon S3 is a storage service that implements Amazon S3-compatible API using Telegram as the storage backend. It allows you to store and retrieve files using standard S3 clients while leveraging Telegram's infrastructure for actual file storage.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages