Added getting file_type by filestream
authorkeatonconrad <keaton.conrad@gmail.com>
Wed, 16 Dec 2020 04:15:59 +0000 (22:15 -0600)
committerkeatonconrad <keaton.conrad@gmail.com>
Wed, 16 Dec 2020 04:15:59 +0000 (22:15 -0600)
tweepy/api.py

index 4a2599c76ff3c653b200271c81d0b9912d0d81d3..1bb16e0ad1f53be96d3525144f7cda98cbe6f825 100644 (file)
@@ -1418,7 +1418,7 @@ class API(object):
 
         # image must be gif, jpeg, png, webp
         if not file_type:
-            file_type = imghdr.what(filename) or mimetypes.guess_type(filename)[0]
+            file_type = imghdr.what(filename, h=f) or mimetypes.guess_type(filename)[0]
         if file_type is None:
             raise TweepError('Could not determine file type')
         if file_type in ['gif', 'jpeg', 'png', 'webp']: