-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Default to octet-stream if mimetype detection fails. #157
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
Default to octet-stream if mimetype detection fails. #157
Conversation
@@ -425,7 +425,11 @@ def __init__(self, filename, mimetype=None, chunksize=DEFAULT_CHUNK_SIZE, | |||
self._filename = filename | |||
fd = open(self._filename, 'rb') | |||
if mimetype is None: | |||
(mimetype, encoding) = mimetypes.guess_type(filename) | |||
# No mimetype provided, make a guess. | |||
(mimetype, _) = mimetypes.guess_type(filename) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Looks mostly good; thank you for the contribution! |
Ping! |
@postmasters: your commit appears to have a different author than it does a committer; is that as you intend it to be? @tmatsuo: want to be a second pair of eyes on this? |
@nathanielmanistaatgoogle I don't understand your comment. Do you see a different email address being used than namnguyen at google.com? The commit should come from that address. |
@postmasters: do you see the text "postmasters committed with Nam T. Nguyen 13 days ago" when you click on the "Commits" tab of this pull request? |
Yes. I don't understand what that line is really saying though. "Nam T. Nguyen" is me. |
Do a |
The function mimetypes.guess_type returns (None, None) if it fails to find a matching extension. In that case, we should just treat the media as application/octet-stream.
Got it. Done. |
Looks good to me too :) |
Default to octet-stream if mimetype detection fails.
When will this be reflected in the PyPI package? |
@Anmol-Singh-Jaggi: It should be reflected in the 1.5.0 PyPI package. |
Great! :D |
The function mimetypes.guess_type returns (None, None) if it fails to
find a matching extension. In that case, we should just treat the media
as application/octet-stream.