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

Handle bytes file input #2233

Merged
merged 7 commits into from
Dec 18, 2020
Merged

Handle bytes file input #2233

merged 7 commits into from
Dec 18, 2020

Conversation

Bibo-Joshi
Copy link
Member

closes #2230

@@ -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.
Copy link
Member

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.

@@ -99,6 +102,8 @@ def is_image(stream: bytes) -> Optional[str]:

@staticmethod
def is_file(obj: object) -> bool:
if isinstance(obj, bytes):
Copy link
Member

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?

Copy link
Member Author

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.

@Bibo-Joshi
Copy link
Member Author

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
@Bibo-Joshi Bibo-Joshi added this to the v13.2 milestone Dec 17, 2020
Copy link
Member

@Poolitzer Poolitzer left a 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

@Poolitzer
Copy link
Member

Tested sending files by (relative) local path in windows, all good

@Bibo-Joshi Bibo-Joshi merged commit 80b3481 into master Dec 18, 2020
@Bibo-Joshi Bibo-Joshi deleted the fix-2230 branch December 18, 2020 10:20
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Handle bytes input for files
3 participants