GithubHelp home page GithubHelp logo

thelebster / s3-bucket-manager-telegram-bot Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 9.0 49 KB

Simple telegram bot that allows upload, download and delete files on S3-compatible storage like AWS S3 and DigitalOcean Spaces.

Dockerfile 2.73% Python 97.27%
telegram-bot s3 aws-s3 python python-telegram-bot bot telegram digitalocean-spaces

s3-bucket-manager-telegram-bot's Introduction

S3 Bucket Manager Telegram Bot

Simple telegram bot that allows upload, download and delete files on S3-compatible storage like AWS S3 and DigitalOcean Spaces.

Built on top of python-telegram-bot.

Configuration

Minimal sample .env file:

TELEGRAM_API_TOKEN=0000000000:AAFBxO9f3HELPkYvaiww0LiNcj6DB-R2d2Q
TELEGRAM_USERNAME=durov
AWS_SERVER_PUBLIC_KEY=AKIAQWERTY4BLSCYBT36
AWS_SERVER_SECRET_KEY=7b79ipOp8sDqycbY4dVSd28TQyaNzyT99PpLJrGO
AWS_REGION=us-east-1
BUCKET_NAME=myuploads

Minimal sample .env file:

TELEGRAM_API_TOKEN=0000000000:AAFBxO9f3HELPkYvaiww0LiNcj6DB-R2d2Q
TELEGRAM_USERNAME=durov
AWS_SERVER_PUBLIC_KEY=DTDINKIYJMAKAUTOEIWV
AWS_SERVER_SECRET_KEY=LBa9U+XUtg7fngBBQuOWXpSgOLULJTk0iaXERS+mlYA
AWS_REGION=ams3
ENDPOINT_URL=https://ams3.digitaloceanspaces.com
CUSTOM_ENDPOINT_URL=https://cdn.example.com
BUCKET_NAME=myuploads

Purge cache

The Spaces API itself does not have support for purging the CDN’s cache, but the DigitalOcean platform API does. The Spaces API was designed to emulate the AWS S3 API so that developers could use it as a drop-in replacement for S3 existing projects. Spaces-specific functionality like the builtin CDN are not part of the S3 API but are support in the DigitalOcean API.

To be able to purge object from the edge caches, you need to obtain a DigitalOcean API token and add to .env file.

DIGITALOCEAN_TOKEN=77e027c7447f468068a7d4fea41e7149a75a94088082c66fcf555de3977f69d3

Deploy/Run

Follow instructions to obtain a token, then paste token to .env file in form of TELEGRAM_API_TOKEN=XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.

docker-compose up -d --build

Usage

/exist image.jpg
/delete image.jpg
/make_public image.jpg
/make_private image.jpg
/copy_file image.jpg assets/image.jpg
/list PREFIX LIMIT
/get_meta image.jpg
/purge_cache image.jpg

TODO

  • Upload single file up tp 20MB
  • Delete single file
  • Copy single file to another path on the same bucket
  • Change access level (make file private or public)
  • Check if file exist
  • List files by prefix
  • Get object metadata
  • Purge the cache (DigitalOcean Spaces)
  • Purge the cache (AWS S3)

Development notes

Update python-telegram-bot (pipenv)

cd s3_bucket_bot
pipenv update python-telegram-bot

or

cd s3_bucket_bot
/usr/local/opt/pipenv/bin/pipenv update python-telegram-bot

Update virtual env (pip)

cd s3_bucket_bot
pip install python-telegram-bot --upgrade

Lock requirements

/usr/local/opt/pipenv/bin/pipenv lock --requirements > requirements.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.