Merge pull request #146 from errbufferoverfl/issue-145-providing-mime-type-raises-exception

Adds statement to open file if MIME type is set and file exists
This commit is contained in:
Lorenz Diener 2018-11-26 11:21:03 +01:00 cometido por GitHub
commit 62bf6afd9f
No se encontró ninguna clave conocida en la base de datos para esta firma
ID de clave GPG: 4AEE18F83AFDEB23

Veure arxiu

@ -1722,6 +1722,8 @@ class Mastodon:
if mime_type is None and os.path.isfile(media_file): if mime_type is None and os.path.isfile(media_file):
mime_type = mimetypes.guess_type(media_file)[0] mime_type = mimetypes.guess_type(media_file)[0]
media_file = open(media_file, 'rb') media_file = open(media_file, 'rb')
elif mime_type and os.path.isfile(media_file):
media_file = open(media_file, 'rb')
if mime_type is None: if mime_type is None:
raise MastodonIllegalArgumentError('Could not determine mime type' raise MastodonIllegalArgumentError('Could not determine mime type'