From 79f51fab70f1dd95120517815c46281306f7f228 Mon Sep 17 00:00:00 2001 From: Harmon Date: Thu, 14 Jan 2021 12:58:29 -0600 Subject: [PATCH] Use proper MIME type for images for chunked media upload Rather than passing only the subtype for the media_type parameter --- tweepy/api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tweepy/api.py b/tweepy/api.py index 91456bc..77bfb3a 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -221,7 +221,11 @@ class API: location = file.tell() h = file.read(32) file.seek(location) - file_type = imghdr.what(filename, h=h) or mimetypes.guess_type(filename)[0] + file_type = imghdr.what(filename, h=h) + if file_type is not None: + file_type = 'image/' + file_type + else: + file_type = mimetypes.guess_type(filename)[0] if chunked or file_type == 'video/mp4': return self.chunked_upload(filename, file=file, file_type=file_type, *args, **kwargs) -- 2.25.1