Skip to content

Commit

Permalink
docs: add readme sendImageFromBase64
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Mar 17, 2021
1 parent f44dc08 commit cddf54b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,16 @@ await client
console.error('Error when sending: ', erro); //return object error
});


// Send image file base64
await client.sendImageFromBase64('[email protected]', base64Image, "name file")
.then((result) => {
console.log('Result: ', result); //return object success
})
.catch((erro) => {
console.error('Error when sending: ', erro); //return object error
});

// Send file (venom will take care of mime types, just need the path)
// you can also upload an image using a valid HTTP protocol
await client
Expand Down Expand Up @@ -486,8 +496,6 @@ await client.sendVideoAsGif(
);




// Send seen ✔️✔️
await client.sendSeen('[email protected]');

Expand Down
11 changes: 5 additions & 6 deletions src/api/layers/sender.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ export class SenderLayer extends ListenerLayer {
}

/**
* Sends image message
* Sends image message base64
* @param to Chat id
* @param base64 File path, http link or base64Encoded
* @param filename
* @param filename
* @param caption
*/
public async sendImageFromBase64(
Expand Down Expand Up @@ -225,7 +225,7 @@ export class SenderLayer extends ListenerLayer {
let mimeType = base64MimeType(base64);

if (!mimeType) {
const obj = {
obj = {
erro: true,
to: to,
text: 'Invalid base64!',
Expand All @@ -251,13 +251,12 @@ export class SenderLayer extends ListenerLayer {
{ to, base64, filename, caption }
);
if (result['erro'] == true) {
reject(result);
return reject(result);
} else {
resolve(result);
return resolve(result);
}
});
}


public async sendMessageOptions(
chat: any,
Expand Down

0 comments on commit cddf54b

Please sign in to comment.