Use telegram as s3 storage.
Enviroment variables you need to set:
API_ID
: Go to my.telegram.org to obtain this.
API_HASH
: Go to my.telegram.org to obtain this.
BOT_TOKEN
: Get the bot token from BotFather.
MONGODB
: MongoDB connect string.
CHAT_ID
: Chat id to send files to.
Setup:
- Create bot in BotFather.
- Obtain API_ID and API_HASH on my.telegram.org.
- Create mongodb database on MongoDB Cloud (or use your server) and copy connect string.
- Insert all variables into .env
- Add bot to your channel with admin rights.
- Run
get_channel_id.py
, send/id
command in your channel. - Copy id to .env
- Create mongodb database named
s3
. - Run
setup_database.py
. - Run
create_accounts.py
to create access keys. - Run
main.py
.
How to use:
import boto3
s3 = boto3.client("s3",
endpoint_url = "your url", # http://127.0.0.1:8000
aws_access_key_id = "your access id",
aws_secret_access_key = "your secret key"
)
s3.create_bucket(Bucket="test_bucket") # create bucket
s3.upload_file("path/to/file", "test_bucket", "file") # upload local file
s3.download_file("test_bucket", "file", "local_file") # download s3 file