-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Handle bytes file input #2233
Handle bytes file input #2233
Conversation
telegram/files/inputfile.py
Outdated
@@ -39,7 +39,7 @@ class InputFile: | |||
attach (:obj:`str`): Optional. Attach id for sending multiple files. | |||
|
|||
Args: | |||
obj (:obj:`File handler`): An open file descriptor. | |||
obj (:obj:`File handler` | :obj:`bytes`): An open file descriptor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc string needs to be adapted.
telegram/files/inputfile.py
Outdated
@@ -99,6 +102,8 @@ def is_image(stream: bytes) -> Optional[str]: | |||
|
|||
@staticmethod | |||
def is_file(obj: object) -> bool: | |||
if isinstance(obj, bytes): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well. It's not accurate that it's a file
What are the implications of reverting this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could make this check in parse_file_input
instead. yeah, maybe the cleaner idea.
Tested sending files by (relative) local path in linux. Waiting for Pool to test on Windows, then we can merge. |
# Conflicts: # telegram/files/inputmedia.py
# Conflicts: # telegram/files/inputmedia.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that looks good to me
Tested sending files by (relative) local path in windows, all good |
closes #2230