Hi all, in last build cannot send pics, it throws error
Error: upload failed: media entry was not created
How to reproduce with example.js?
This seems to be working fine for me.
Are you running from the version in the master branch?
@Aliyss can you check if this happens to you, if you don't mind?
All of the sudden, I am now getting this issue. I'm investigating.
@pedroslopez All fine for me. Running on latest commit.
Yeah I'm confused. Doing the same steps, most times it works but sometimes it doesn't and I'm not sure why. I'm still looking into why it fails.
@JRakhimov I have released version 1.0.1 which should fix this issue. Please let me know if this solves it or if you still have issues.
@pedroslopez Thank you, today/tomorrow I will take a look
Hello friends, I'm a little lost on how to send an image, can someone give me an example?
Is like:
msg.reply(new MessageMedia(how do i put it here?));
Hello friends, I'm a little lost on how to send an image, can someone give me an example?
Is like:msg.reply(new MessageMedia(how do i put it here?));
Hi @ev4ndropc !
To send media, the first thing you'll need is a base64-encoded file. Let's take the WhatsApp icon, for example:

This image, as base64, would be the following:
const base64 = 'iVBORw0KGgoAAAANSUhEUgAAAgAAAAIAC(...)';
Note that I've only included the first few characters from the base64 string, because it is very long.
Next you'll need the mimetype for the file you're sending. In this case, it's a png image, so...
const mimetype = 'image/png';
Now we can construct our MessageMedia:
const media = new MessageMedia(mimetype, base64);
If you're sending a document, such as a .docx or .xls you can also specify a filename as a third argument.
You can now send this to a chat through any of the sendMessage or reply functions available. As an example let's just assume we're replying to a message:
message.reply(media);
We could also specify a caption:
message.reply(media, {caption: "Here's your media!"});
Or send it as part of the options object:
message.reply("Here's your media!", {media: media});
{caption: "Here's your media!"}
@pedroslopez
Thanks my friend for your help with the beginners, I was able to upload, but which site do you use to convert the images to base64? Some sites form a string that gives an error. I'll delete my questions so I don't pollute here
@ev4ndropc
We've taken over this issue which was meant for something else entirely, but I'll reply to this message and if you have more questions please open a new issue for this matter.
If you're looking for an online solution I've used https://www.base64-image.de/ in the past, but I would opt for generating it myself through javascript.
Please note that these sites usually give you a data url, which is slightly different. For example, the site I linked outputs the following for the whatsapp image I referred to earlier:
data:image/png;base64,iVBORw0KGgoAAAANS(...)
again, I've cut off the string because it is very long.
Note that the first part data:image/png indicates the mimetype. The data part is actually the bit after the comma (iVBORw0KGgoAAAANS...). If you want to do it programmatically, you can get the data part of a data url using the following:
const data = dataUrl.split(',')[1];
@pedroslopez Hi. I got the same problem.
Its happened when im tried send base64 image,which has never sent . For example, im save base64 data
in file .txt. Then i read it and split, getting mimetype and data, then creating MediaMessage. But when i try to send this using
client.sendMessage();
```
or
```javascript
msg.reply()
I got following error:
Evaluation failed: Error: upload failed: media entry was not created
I can fix this if I send this picture manually, and then try again. Then everything works fine. And so with all the pictures. At the same time, chat does not affect this. If I upload a picture in one chat I can send it to everyone else.
This is my code:
if (msg.body == '!ping') {
// Send a new message to the same chat
const arr = fs.readFileSync('./data.txt')
.toString()
.split(',');
var mime = arr[0].match(/:(.*?);/)[1];
var mm = new MessageMedia(mime, arr[1]);
client.sendMessage(msg.from, mm, { caption: 'please send itPLEASE' });
msg.reply(mm)
//client.sendMessage(msg.from, 'pong');
}
Full traceback
UnhandledPromiseRejectionWarning: Error: Evaluation failed: Error: upload failed: media entry was not created
at Object.window.WWebJS.processMediaData (__puppeteer_evaluation_script__:74:19)
at async Object.window.WWebJS.sendMessage (__puppeteer_evaluation_script__:7:26)
at async __puppeteer_evaluation_script__:2:25
at ExecutionContext._evaluateInternal (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\ExecutionContext.js:122:13)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async ExecutionContext.evaluate (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\ExecutionContext.js:48:12)
at async Client.sendMessage (F:\Repos\Visual stdio\Server-bot.Work\asd\src\Client.js:266:28)
-- ASYNC --
at ExecutionContext.<anonymous> (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\helper.js:111:15)
at DOMWorld.evaluate (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\DOMWorld.js:112:20)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
-- ASYNC --
at Frame.<anonymous> (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\helper.js:111:15)
at Page.evaluate (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\Page.js:860:43)
at Page.<anonymous> (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\helper.js:112:23)
at Client.sendMessage (F:\Repos\Visual stdio\Server-bot.Work\asd\src\Client.js:266:47)
at Message.reply (F:\Repos\Visual stdio\Server-bot.Work\asd\src\structures\Message.js:177:28)
at Client.<anonymous> (F:\Repos\Visual stdio\Server-bot.Work\asd\example.js:61:13)
at Client.emit (events.js:210:5)
at F:\Repos\Visual stdio\Server-bot.Work\asd\src\Client.js:154:18
at Page._onBindingCalled (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\Page.js:558:56)
at CDPSession.<anonymous> (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\Page.js:119:54)
-- ASYNC --
at Page.<anonymous> (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\helper.js:111:15)
at Client.sendMessage (F:\Repos\Visual stdio\Server-bot.Work\asd\src\Client.js:266:47)
at Message.reply (F:\Repos\Visual stdio\Server-bot.Work\asd\src\structures\Message.js:177:28)
at Client.<anonymous> (F:\Repos\Visual stdio\Server-bot.Work\asd\example.js:61:13)
at Client.emit (events.js:210:5)
at F:\Repos\Visual stdio\Server-bot.Work\asd\src\Client.js:154:18
at Page._onBindingCalled (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\Page.js:558:56)
at CDPSession.<anonymous> (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\Page.js:119:54)
at CDPSession.emit (events.js:210:5)
at CDPSession._onMessage (F:\Repos\Visual stdio\Server-bot.Work\asd\node_modules\puppeteer\lib\Connection.js:200:12)
(node:4644) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
Sorry... Im dont check yesterday update. Im so stupid. Its just because i tried fix this problem 2 days. Sorry
@pedroslopez Excellent, everything works fine, even with video. Yeah, about video, for this purpose you should use Google Chrome instead of Chromium. It it bcz of licenses in chrome versions. More
@pedroslopez Excellent, everything works fine, even with video. Yeah, about video, for this purpose you should use Google Chrome instead of Chromium. It it bcz of licenses in chrome versions. More
Oh! So you just used Chrome and sending video works?
That鈥檚 great to know. Glad this fixed your issue.