wppconnect icon indicating copy to clipboard operation
wppconnect copied to clipboard

Cannot send picture from Base64

Open gekkedev opened this issue 7 months ago • 1 comments

Description

Images cannot be sent as picture As reference image, I'm taking a screenshot:

const picture = await client.takeScreenshot()
console.log(picture) //logs valid and displayable base64
console.log(
  JSON.stringify(
    await client.sendImageFromBase64(message.chatId, picture, "Screenshot_20240627-153045_WhatsApp.jpg")
    //error:    [session:client] [object Object]
  )
)

console.log(
  JSON.stringify(
    await client.sendFileFromBase64(message.chatId, picture, "Screenshot_20240627-153045_WhatsApp.jpg")
    //[session:client] Error: Empty or invalid file or base64
  )
)

Environment

  • WPPConnect version(s): 1.32.3
  • WA-JS version(s): 3.4.1
  • Browser: Chrome @ latest
  • OS: Windows 11
  • Node version: Node 18
  • WhatsApp version: 2.3000.1013991265
  • MultiDevice (BETA): no

Steps to Reproduce

  1. use this code
  2. send a message
  3. try the file-sending method, same issue but a more detailed error

Log Output

sendImageFromBase64:

error:    [session:client] [object Object]

wrapping this in a try/catch structure yields this:

{ erro: true, to: '123456***[email protected]', text: 'Invalid base64!' }

sendFileFromBase64:

[session:client] Error: Empty or invalid file or base64

Additional context / Screenshot

did not try it with other pictures yet, so there could be an issue with the screenshot creation function's output (although it is displayable)

gekkedev avatar Jun 27 '24 12:06 gekkedev