mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.04k stars 795 forks source link

how upload pdf #1000

Open arvind1kumar1 opened 3 years ago

arvind1kumar1 commented 3 years ago

Please tell me how upload pdf in whatsapp. When i tried to upload a pdf it throw a error that message does not have save_media method.

jeanRibeiro commented 3 years ago

I'm with same problema

wherculano commented 3 years ago

In my case, when I tried to send a pdf file, it always send a corrupted file (in my phone I got a TXT file instead of a PDF and on my laptop I received a corrupt PDF). Any clues of how to fix this?

marcelocmenezes commented 3 years ago

Please tell me how upload pdf in whatsapp. When i tried to upload a pdf it throw a error that message does not have save_media method.

can you upload to a cloud service as aws s3? in my case my client upload to s3 and send link to API equal on Positus Business WhatsApp API.

def convert_media_url_to_base64(self, url):
        mime = magic.Magic(mime=True)
        archive = ''
        buffer = urllib.request.urlopen(url).read()
        content_type = mime.from_buffer(buffer)
        archive = b64encode(buffer)
        archive = archive.decode('utf-8')
        return 'data:' + content_type + ';base64,' + archive
 def send_media_from_url(self, url, chatid, caption):
        imgBase64 = self.convert_media_url_to_base64(url)
        filename = url.split('/')[-1]
        return self.wapi_functions.sendImage(imgBase64, chatid, filename, caption)