-
Notifications
You must be signed in to change notification settings - Fork 152
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
Reset image stream position after using tell #105
Reset image stream position after using tell #105
Conversation
Nice catch. |
I'll run down some more test cases. I've mostly been testing this against Google Cloud Storage but it shouldn't really make much of a difference. |
Thanks again. It's not the storage I'm worried about; it's the forthcoming attributes that are applied. Just test it against PNG, JPEG, and SVG files. If they all work, then we're good to go. |
What would you like me to look for besides the upload working and displaying inline in admin? The file types are correct in storage (I'm testing locally to rule out any Google weirdness). JPEG, PNG and SVG all seem to work for me. |
Nothing... We're all good if all the uploads are working. Is Google storage really that weird? I keep hearing about it! |
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.
Confirmed on different image formats.
Confirmed in admins (upload + preview).
I know - and how I wish to see the back of Python 2! Would you mind adding this recommendation to #60 - just so we won't forget! Or better yet, just change it yourself and send a pull request our way. We are dropping Python 2 support in the next version, so... |
Eh, I wouldn't say that GCS is all that weird. You just can't necessarily treat it like a normal file stream. At least that's the case for the Google-provided Python library. 👍 for the Python 3 love |
For uploads, I noticed that using django-markdownx with something like django-storages doesn't work because the image stream position is set to the end of the steam when the
InMemoryUploadedFile
is instantiated. Simply resetting the image stream position back to the beginning should do the trick.In the future, when you guys drop Python 2 support, something like getbuffer or getvalue could be used to get the length of the buffer instead of using
tell
.