"""
f = kwargs.pop('file', None)
- file_type = imghdr.what(filename, h=f.read()) or mimetypes.guess_type(filename)[0]
+ if f is None:
+ file_type = imghdr.what(filename) or mimetypes.guess_type(filename)[0]
+ else:
+ file_type = imghdr.what(filename, h=f.read()) or mimetypes.guess_type(filename)[0]
if file_type == 'gif':
max_size = 14649
else:
# image must be gif, jpeg, png, webp
if not file_type:
- file_type = imghdr.what(filename, h=f.read()) or mimetypes.guess_type(filename)[0]
+ if f is None:
+ file_type = imghdr.what(filename) or mimetypes.guess_type(filename)[0]
+ else:
+ file_type = imghdr.what(filename, h=f.read()) 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']: