Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_file_stream support #944

Closed
lekoOwO opened this issue Dec 21, 2017 · 2 comments · Fixed by #1019
Closed

get_file_stream support #944

lekoOwO opened this issue Dec 21, 2017 · 2 comments · Fixed by #1019

Comments

@lekoOwO
Copy link

lekoOwO commented Dec 21, 2017

node-telegram-bot-api has added getFileStream method , which allows accessing the file stream without downloading it to a folder. It'll be useful.For example, changing a group photo from a photo uploaded by users.

@JosXa
Copy link
Contributor

JosXa commented Dec 21, 2017

This is fairly easily done in python code. But I agree in that it is a very common question and it might make sense to abstract the functionality for our users as a convenience method...

@jsmnbom
Copy link
Member

jsmnbom commented Dec 30, 2017

You mean like downloading a file to a BytesIO object?
If so, this can already be done as so:

def document(bot, update):
    doc = update.effective_message.document
    file = bot.get_file(doc.file_id)
    with io.BytesIO() as content:
        file.download(out=content)
        do_something_with_content(content)

Though I agree that it could perhaps be simplified somewhat.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants