-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get contact profile picture in base64 and not in URL #1542
Comments
just fetch it using node-fetch (it is a peer dependency by puppeteer so no installation needed) (also in Node 17+, this is a built-in feature, just use the function)
const url = await client.getProfilePicUrl(chatId);
const res = await fetch(url);
const data = {data: (await res.arrayBuffer()).toString('base64'), mimetype: res.headers.get('Content-Type')}; |
As for your concerns, the image can get quite large and you will be using resources to copy an image in pure arraybuffer to the client. And also sometimes the cached image isn't the latest, which might bring even more concern.. Thanks for your suggestion though |
Just a minor correction: I am pretty sure it's supposed to be the contact's WhatsApp ID and not the chat ID, according to the docs and what I've tried. But please do let me know if I am wrong. |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe.
Currently, if I want a profile picture of a contact or a group, I get the URL.
for example: https://docs.wwebjs.dev/Client.html#getProfilePicUrl (similar method on the Contact class)
From what I understand, the image can be downloaded by the browser via puppeteer, so I would prefer that it is available in base64.
Describe the solution you'd like.
add an a method Client.getProfileMedia() which will return Promise of { mimetype: string, data: string}
Describe an alternate solution.
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: