pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.53k stars 3.7k forks source link

How do I save received images and documents? #3269

Closed MillesC closed 2 months ago

MillesC commented 2 months ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe.

I have tried several ways to save received images or files to a file, but I have not been able to do so. Thanks for your answers.

Describe the solution you'd like.

Save received images and documents

Describe an alternate solution.

No response

Additional context

No response

MillesC commented 2 months ago
else if (msg.body === '!mediainfo' && msg.hasMedia) {
        const attachmentData = await msg.downloadMedia();
        msg.reply(`
            *Media info*
            MimeType: ${attachmentData.mimetype}
            Filename: ${attachmentData.filename}
            Data (length): ${attachmentData.data.length}
        `);
    **The console response is:**
    (node:18132) UnhandledPromiseRejectionWarning: TypeError: msg.downloadMedia is not a function

In fact, the API responds, but what I need is to download the image or document

alechkos commented 2 months ago

1621