Skip to main content

A lightweight, high-performance file storage API using Telegram as a backend.

Project description

📦 TG Storage Cluster

Python FastAPI License Developer

A lightweight, high-performance file storage API that transforms Telegram into an infinite, scalable backend.


🚀 Installation

Install the package directly via pip:

pip install tgstorage-cluster

🛠️ Setup & Usage

1. Configuration

The package looks for a .env file and a tokens.txt file in your current working directory.

  1. Create a .env file:
API_ID=your_id
API_HASH=your_hash
CHANNEL_ID=your_channel_id
ADMIN_API_KEY=your_secret_key
BASE_URL=http://localhost
  1. Create a tokens.txt file and add your bot tokens (one per line).

2. Run the Server

You can start the storage server using the built-in CLI command:

tgstorage

The server will start on http://localhost:8082.

3. Generate API Keys

Manage your client keys using the management CLI:

tgstorage-key --owner "MyWebApp"

📦 Integration in your Python Code

You can use the cluster logic directly in your own projects without running the FastAPI server:

import asyncio
from tgstorage.bot import cluster

async def upload_something():
    # It will automatically load config from your current directory's .env
    bot = await cluster.get_healthy_bot()
    with open("image.png", "rb") as f:
        msg = await bot.send_document(
            chat_id=-100123456789, 
            document=f, 
            filename="image.png"
        )
    print(f"File uploaded! Message ID: {msg.message_id}")

asyncio.run(upload_something())

📜 License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tgstorage_cluster-1.0.2.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tgstorage_cluster-1.0.2-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file tgstorage_cluster-1.0.2.tar.gz.

File metadata

  • Download URL: tgstorage_cluster-1.0.2.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for tgstorage_cluster-1.0.2.tar.gz
Algorithm Hash digest
SHA256 810dd0142f712782b6ef448e4cd7af35224c37acc1b485750e5a7d1df246043e
MD5 56723e2b449896dbd1abfea0fe231cec
BLAKE2b-256 4c3ff17d4b7e5809115fb07052aadf2b3947f6f7bd3012298387cbb31484315a

See more details on using hashes here.

File details

Details for the file tgstorage_cluster-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for tgstorage_cluster-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ff34d32035d9a371abaf1d414c18e1eb7d615361305e504caa4ab7aa6e67dfc1
MD5 94f9832d634d5983188a049527b3f8a9
BLAKE2b-256 7f30772e7f41dcdf92a5d961956348c79a4e6849a76e8b27e0b402a03314b2a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page