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
14.62k stars 3.48k forks source link

MessageMedia.filesize is undefined despite .data being defined #1998

Closed mmaeffert closed 7 months ago

mmaeffert commented 1 year ago

Is there an existing issue for this?

Describe the bug

When accessing the .filesize attribute of the MessageMedia object I get returned from the method downloadMedia(), it is undefined, despite the .data attribute being defined.

Expected behavior

Getting the resulting filesize of the MessageMedia object

Steps to Reproduce the Bug or Issue

` try { message.downloadMedia().then((sticker) => {

        //This returns undefined
        console.log(sticker.filesize)
    })
} catch {
    message.reply("Failed")
}`

Relevant Code

No response

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

No, I am not using Multi Device

Environment

Additional context

Happens when downloading stickers.

My Workaround: unescape(atob(sticker.data)).length

amosayomide05 commented 1 year ago

Save the media using FS temporarily and get the filesize

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.