Enable downloading to existing file-objects, instead of using file paths#425
Enable downloading to existing file-objects, instead of using file paths#425akiross wants to merge 3 commits intopython-telegram-bot:masterfrom
Conversation
The `download_to` method uses the provided file-object to store the data. This allows to use memory buffers as well as temporary files without having to pass by a file name.
|
I definitely think we should have a method like this, I'm just not sure about the naming. To me |
|
First, let me apologize because I don't understand where the code issue is. The code is running fine on my test bot, and I am not expert at all with travis and coverall. Any suggestion is welcome, so I can try to fix. Second, yes: I thought about the naming as well. My first idea is to make So I thought about passing a new, optional parameter for the file object, but this means that the current parameter has to be made optional as well, leading to have an API where two parameters are both optional, but one is required, and their use is mutually exclusive. Not a really clear choice, I believe. So I thought about a separated method. Yes, |
|
Closing in favour of #459 |
I would like to propose to introduce a new method,
download_to, that uses a file-like object where data is written. This allows to download to memory as well as to temporary files, without having the user to know the file path.This may be useful for bots where the file does not need to be stored, for example for describe-the-image bots or bots that modify the image on-the-fly and send it back, without having to store it.