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
Conversation
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.
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.
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.
#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.
Co-authored-by: Harmon <Harmon758@gmail.com>
Since this is one of the last remaining PRs I want to include for v3.10, I've gone ahead and resolved the conflicts. |
Allows the
media_upload()
and_pack_image()
functions to guess the file type from BytesIO data. All this does is pass in the already-existingfile
/f
parameters toimghdr
to guess the file type and allow the data to be processed as if it were a file.