Sign inSign up

deptyped/telegram-file-proxy

By deptyped

Updated 10 months ago

Provide links to files by file_id without exposing bot token

Image
0

969

deptyped/telegram-file-proxy repository overview

📁 Telegram File Proxy

Docker Image Size (latest semver)

Introduction

This proxy allows you to provide users with links to files by file_id without exposing your bot's token. This is especially useful for the Telegram Web Apps feature, as it enables you to use files from Telegram directly in your web app.

To get a link to a file, simply pass file_id of the file as the path:

http://telegram-file-proxy/<file_id>
Query Parameters

You can also use query parameters to control response headers:

  • content-type: Sets the Content-Type header. The value must be one of the pre-approved MIME types (e.g., image/jpeg, video/mp4, application/pdf). If the value is not allowed, the header will be omitted.

    http://telegram-file-proxy/<file_id>?content-type=image/png
    
  • filename: Sets the filename in the Content-Disposition header. This suggests a name for the file when the user downloads it.

    http://telegram-file-proxy/<file_id>?filename=document.pdf
    

You can combine both parameters:

http://telegram-file-proxy/<file_id>?content-type=image/jpeg&filename=photo.jpg
Configuration
ENV nameCLI nameDescription
BOT_TOKENbot-tokenBot token
SERVER_PORTserver-portServer port (8080 by default)
SERVER_HOSTserver-hostServer hostname
API_ROOTapi-rootBot API Root (https://api.telegram.org by default)
API_LOCALapi-localAllow providing files from the file system, useful when using a Local Bot API with the --local option (0 by default)

Configuration is loaded in layers. Command-line flags take precedence over environment variables.

Using Docker Compose
version: "3"
services:
  telegram-file-proxy:
    image: deptyped/telegram-file-proxy
    ports:
      - "8080:80"
    environment:
      - BOT_TOKEN= # <-- place your bot token here
      - SERVER_PORT=80

Or configuration with command line arguments:

version: "3"
services:
  telegram-file-proxy:
    image: deptyped/telegram-file-proxy
    ports:
      - "8080:80"
    command: --bot-token <place your bot token here> --server-port 80
Using Docker Compose with a Local Bot API Server
version: "3"
services:
  telegram-file-proxy:
    image: deptyped/telegram-file-proxy
    ports:
      - "8080:80"
    volumes:
      - "./data:/var/lib/telegram-bot-api"
    environment:
      - BOT_TOKEN= # <-- place your bot token here
      - SERVER_PORT=80
      - API_ROOT=http://bot-api:8081
      - API_LOCAL=1

  bot-api:
    image: aiogram/telegram-bot-api:latest
    ports:
      - "8081:8081"
    volumes:
      - "./data:/var/lib/telegram-bot-api"
    environment:
      - TELEGRAM_LOCAL=1
      # Create an application with api id and api hash (get them from https://my.telegram.org/apps)
      - TELEGRAM_API_ID= # <-- place your api id here
      - TELEGRAM_API_HASH= # <-- place your api hash here

Tag summary

Content type

Image

Digest

sha256:56c956761

Size

5.2 MB

Last updated

10 months ago

docker pull deptyped/telegram-file-proxy