Skip to content

Latest commit

 

History

History
88 lines (70 loc) · 3.02 KB

README.md

File metadata and controls

88 lines (70 loc) · 3.02 KB

TGBucket

Open source project that provide simple HTTP API to upload and download files to/from Telegram.
Use directly MTProto protocol to upload files up to 2GB with a simple bot token.
Based on NestJS framework.

Features

  • Upload any files
  • Download uploaded files
  • Resend message with file

Requirements

  • node
  • postgres
  • pnpm

Docker

Deploy ready container avaiable on DockerHub

Getting Started

Environment variables

env required description
DATABASE_URL yes Database connection URL
TELEGRAM_API_ID yes Application ID from your Telegram App
TELEGRAM_API_HASH yes Application hash from your Telegram App
TELEGRAM_BOT_TOKEN yes Telegram bot token
TELEGRAM_CHAT_ID yes Chat ID to upload files

Installation

  • Copy .env.example, rename to .env and setup all variables

  • Install dependencies

    pnpm install
  • Build project

    pnpm build:prod
  • Start application

    pnpm start:prod
  • Open localhost:3000 and see ok message (default port: 3000)

API

POST / - File upload

Request:
Accept binary file
Require Content-Type and Content-Length headers.
Optionally can be passed X-Filename header to save filename to uploaded file. Saved file name will be used when downloading.
Max file size - 2000MiB

Response:
Return JSON serialized FileEntity

GET /:id - Download file

Request:
Require id of uploaded file in url\

Response:
Return binary file stream with Content-Type and timestamp in filename. OR use custom filename if wass passed X-Filename header on upload.

POST /:id/resend - Send file in message

Request:
Require id of uploaded file in url and JSON body:

{ "peerId": "myTgUsername", "message": "optional" }

Response:
Nothing

How to Contribute

  • Fork and clone this repository
  • Commit your changes
  • Create a pull request to master branch

Or, just send us an issue for reporting bugs or ask questions and share your ideas, etc in discussions.