From 64b42e560a71d3bbcf9cb47f039e158a860eb979 Mon Sep 17 00:00:00 2001 From: Harmon Date: Sun, 2 Aug 2020 15:00:37 -0500 Subject: [PATCH] Use proper MIME type in Content-Type header for uploaded images Fixes regression introduced with #1086 where Content-Type headers of uploaded images did not use proper MIME type structure and only specified the subtype --- tweepy/api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tweepy/api.py b/tweepy/api.py index ba047d3..4a2599c 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -1421,7 +1421,9 @@ class API(object): file_type = imghdr.what(filename) or mimetypes.guess_type(filename)[0] if file_type is None: raise TweepError('Could not determine file type') - if file_type not in ['gif', 'jpeg', 'png', 'webp', 'image/gif', 'image/jpeg', 'image/png']: + if file_type in ['gif', 'jpeg', 'png', 'webp']: + file_type = 'image/' + file_type + elif file_type not in ['image/gif', 'image/jpeg', 'image/png']: raise TweepError('Invalid file type for image: %s' % file_type) if isinstance(filename, six.text_type): -- 2.25.1