tdlib / telegram-bot-api

Telegram Bot API server
https://core.telegram.org/bots
Boost Software License 1.0
3.23k stars 606 forks source link

Cannot download file #59

Closed zickkeen closed 3 years ago

zickkeen commented 3 years ago

Where are the files located? I'm using a generic url: https://hostlocal.api/file/bot<token>/path/file_id.ext and https://hostlocal.api/file/bot<token>/<file_path>?file_id=<file_id> But the return always:

{
"ok": false,
"error_code": 404,
"description": "Not Found"
}
levlam commented 3 years ago

The files are downloaded to bot's folder inside server's working directory. You need to set up your HTTPS server serve static files from subfolders of these folders. "/file/bot<token>/path/file_id.ext" should be translated to a path "<server's working directory>/<token>/path/file_id.ext".

zickkeen commented 3 years ago

That means we have to set up an http/https server to serve these folders/files?

levlam commented 3 years ago

Yes. You already have a HTTPS server to serve https://hostlocal.api. You need to set up it to serve files also.

zickkeen commented 3 years ago

can we run telegram-bot-api in https mode?

levlam commented 3 years ago

No. You must have an SSL-terminating web server,

noplanman commented 3 years ago

I'm busy implementing this functionality to the @php-telegram-bot

@levlam So basically tdlib does not offer any way to access the files via its internal HTTP server? i.e. We need to set up a separate webserver that proxies the files?

levlam commented 3 years ago

@noplanman Yes. Bot API server downloads files and saves them locally. In --local mode it returns full path to the file, otherwise it returns a relative path to the file, which can be then served using any HTTPS server.

noplanman commented 3 years ago

@levlam Ok, thanks for the confirmation 👌

marcoslp010 commented 1 year ago

If you, like me, are not willing to create a server just to serve files, you can change the url to the default Telegram url (api.telegram.org), here it worked perfectly

levlam commented 1 year ago

@marcoslp010 You must not use api.telegram.org and a local server at the same time.

marcoslp010 commented 1 year ago

@marcoslp010 You must not use api.telegram.org and a local server at the same time.

use and only for downloading attachments

AYMENJD commented 1 year ago

@marcoslp010 You must never use them both for any purpose. Even for downloading. Otherwise you will ran into too many issue with your bot.