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

Allows media upload from BytesIO #1475

Merged
merged 6 commits into from Dec 26, 2020
Merged

Allows media upload from BytesIO #1475

merged 6 commits into from Dec 26, 2020

Conversation

keatonconrad
Copy link
Contributor

Allows the media_upload() and _pack_image() functions to guess the file type from BytesIO data. All this does is pass in the already-existing file/f parameters to imghdr to guess the file type and allow the data to be processed as if it were a file.

Copy link
Member

@Harmon758 Harmon758 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this reads the entire file to pass it to imghdr.what and the file object's position isn't reset, an empty string ends up being uploaded as the image.

@Harmon758 Harmon758 added Improvement This is regarding an improvement to an existing feature Need Follow-Up This needs to be followed up on to be actionable labels Dec 22, 2020
@Harmon758 Harmon758 linked an issue Dec 22, 2020 that may be closed by this pull request
Copy link
Member

@Harmon758 Harmon758 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1413 has been merged now, so this PR now has conflicts that should be resolved in favor of the changes to media_upload from that PR.

tweepy/api.py Outdated Show resolved Hide resolved
Co-authored-by: Harmon <Harmon758@gmail.com>
@Harmon758 Harmon758 added this to the 3.10 milestone Dec 25, 2020
@Harmon758
Copy link
Member

Since this is one of the last remaining PRs I want to include for v3.10, I've gone ahead and resolved the conflicts.

@Harmon758 Harmon758 merged commit cf19a59 into tweepy:master Dec 26, 2020
@Harmon758 Harmon758 removed the Need Follow-Up This needs to be followed up on to be actionable label Dec 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement This is regarding an improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileNotFoundError in api.media_upload using the file argument
2 participants