Giter VIP home page Giter VIP logo

Comments (7)

levlam avatar levlam commented on July 18, 2024 3

You don't have uploading progress with Bot API. HTTP doesn't have any progress notifications. At most, you can know number of sent bytes, which after some time will or won't reach Telegram servers. All incoming HTTPS requests at api.telegram.org are handled by Nginx web server. Uploaded files are stored locally by Nginx. After the file is fully uploaded to the Nginx server, the request is passed to Telegram Bot API server. It receives the file in an HTTP request and saves it locally to a temporary folder. Only after the file is fully received by the Bot API server, uploading of the file to Telegram servers begins. There is no way, you can know real file upload progress in this scenario.

If you use local Bot API server, then you can eliminate Nginx step, but you still can't know file upload progress.

With TDLib and Telegram API according to this https://core.telegram.org/api/files we know part_size, count of parts and completely control upload process with upload.saveBigFilePart so we know current progress

TDLib doesn't provide direct access to Telegram API or upload.saveBigFilePart. This is completely irrelevant to what is provided by TDLib.

If you want to know real file upload progress, you need to proxy somehow updateFile updates handled in

void Client::on_update_file(object_ptr<td_api::file> file) {
to your app. There is no way, you can do this using HTTP/1.1.

from telegram-bot-api.

n2j7 avatar n2j7 commented on July 18, 2024

Thanks a lot! This is the more detailed explanation I've ever seen for the Telegram Bot API.

It's a common case to upload files via the API, so yes, you're right, there is no way to know the progress of the upload.
But this can be a big advantage for using telegram-bot-api server locally!

By default (I mean using the api.telegram.org server) you can upload up to 50MB files and the upload progress doesn't really matter as it is counted in fractions of a second. With files up to 20 << 20 bytes this can take a long time (minutes I think)

I may be wrong with TDLib, but as described here https://core.telegram.org/api
The Telegram and TDLib APIs allow you to create your own customized Telegram clients.
For me, this means that I can use TDLib and the Telegram API to create my own client to upload files (and I do have one).

After my file has been uploaded by this "client", I can send this file to the bot, and then the bot will be able to work with this file.

Inside the "client" I split the file into chunks (512KB each) and upload them separately (in parallel and in a queue) so I know the progress for each file. I've built my own infrastructure around this and hope your solution with a upload progress endpoint can make my life easier

I understand that Bot API and Client API are different and work differently, but it would be great to have this feature in telegram-bot-api-server

Thanks for the advice on proxying updateFile, I'll try to work with it. I don't want to handle upload progress in the same connection, i want some extra point to control this.

Thanks anyway for your work !!! It is awesome!

from telegram-bot-api.

levlam avatar levlam commented on July 18, 2024

Bot API works over HTTP and there is no way in HTTP/1.1 to notify about any progress. This makes impossible to add this feature to the Bot API.

from telegram-bot-api.

luckydonald avatar luckydonald commented on July 18, 2024

One idea would be that you provide some kind of unique string with your uploads (maybe upload_id) under which it would get tracked and you could then have a separate endpoint to check for upload progress using the same upload_id you assigned yourself.

from telegram-bot-api.

n2j7 avatar n2j7 commented on July 18, 2024

@luckydonald Actually, the full filename (path + base name) or just filename is enough and you don't need to change the bot api for that ... I'll try to implement that soon ...

from telegram-bot-api.

luckydonald avatar luckydonald commented on July 18, 2024

@n2j7 Do you have the filename even available before the upload is finished? I thought it is generated by the api after the download?

from telegram-bot-api.

n2j7 avatar n2j7 commented on July 18, 2024

I'm talking about using the service with the --local flag, so yes, the file is on the local filesystem. file_id will be available only after uploading

from telegram-bot-api.

Related Issues (20)

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.