Comments (7)
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
telegram-bot-api/telegram-bot-api/Client.cpp
Line 3741 in 9692d58
from telegram-bot-api.
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.
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.
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.
@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.
@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.
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)
- How can I be sure that Telegram BOT API local server is running properly? HOT 4
- Blockquote HTML syntax issues HOT 1
- pending_update_counts delay HOT 15
- get 404 error on download file! HOT 11
- Bot latency HOT 6
- Failed to forward message: 'Bad Request: message thread not found' HOT 7
- Persistent "ERROR" When Creating Telegram Application HOT 6
- Change the maximum upload size HOT 1
- not able to set more webhooks! HOT 9
- Too few replies to incoming private messages. Conversion is 0% HOT 1
- [ASK] Why not found method getinvoicelink ? HOT 4
- Reactions order in MessageReactionUpdated is not preserved? HOT 3
- message_reaction treats supergroup itselfs reaction as from private chat HOT 2
- Rouse
- Error sending fileid of flac audio in inline request HOT 6
- tele
- Unpaired UTF-8 Bidi Control Character Detected During Build HOT 3
- add WebApp.navigateTo() into the telegram web app js script HOT 1
- Idle Timeout Expired HOT 3
- send file HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegram-bot-api.