I'm trying to upload a photo using telepot python library in a telegram bot.
fd, path = tempfile.mkstemp()
image_bytes = requests.get(url=fileUrl, stream=True)
with open(path, 'wb') as strm:
for chunk in image_bytes:
strm.write(chunk)
photoFile = open(path, mode='rb')
fileId = bot.sendPhoto(chat_id='chat_id', photo=photoFile)
This code gives me this error:
telepot.exception.TelegramError: ('Bad Request: type of file mismatch', 400, {'ok': False, 'error_code': 400, 'description': 'Bad Request: type of file mismatch'})
If I try to access to the local file created by tempfile.mkstemp(), it exists and gives the correct image. I also tried specifying the extension of the image in the image name but there is still the same error.
Thanks for your help