Telegram send image: fix mimetype detection (#7802)
* Add `name` var to BytesIO content to get recognized Sometimes the python-telegram-bot doesn't recognize the mimetype of the file and looks after a name variable to deduce it. Fixes #7413 * bytesio stream recycle less explicitpull/4794/merge
parent
5e5c0daa87
commit
f7e0d13fe6
|
@ -180,6 +180,7 @@ def load_data(url=None, filepath=None,
|
|||
data = io.BytesIO(req.content)
|
||||
if data.read():
|
||||
data.seek(0)
|
||||
data.name = url
|
||||
return data
|
||||
_LOGGER.warning("Empty data (retry #%s) in %s).",
|
||||
retry_num + 1, url)
|
||||
|
@ -503,7 +504,7 @@ class TelegramNotificationService:
|
|||
_LOGGER.debug("send file to chat_id %s. Caption: %s.",
|
||||
chat_id, caption)
|
||||
self._send_msg(func_send, "Error sending file",
|
||||
chat_id, io.BytesIO(file_content.read()),
|
||||
chat_id, file_content,
|
||||
caption=caption, **params)
|
||||
file_content.seek(0)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue