open-wa / wa-automate-python

💬 🤖 The most advanced Python whatsapp library for chatbots with advanced features. Be sure to ⭐ this repository for updates!
Other
342 stars 74 forks source link

[QUESTION] SendImage using base64, instead of the imagepath #50

Closed GauthamramRavichandran closed 3 years ago

GauthamramRavichandran commented 3 years ago

send_media gets the imagepath and it converts into a base64 and sends it.

def send_media(self, path, chatid, caption):
        imgBase64 = convert_to_base64(path)
        filename = os.path.split(path)[-1]
        return self.wapi_functions.sendImage(imgBase64, chatid, filename, caption)

I tried to pass a base64 img string directly to sendImage, but it was failing. How can I send image using base64?

mrodal commented 3 years ago

you could take a look at what convert_to_base64 does to get the base64 from the source image

GauthamramRavichandran commented 3 years ago

Got it, need to add the mimetype within that string itself. Thank you!