Skip to content
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

How does the sendDocument method work? #308

Open
menelai opened this issue Nov 6, 2020 · 0 comments
Open

How does the sendDocument method work? #308

menelai opened this issue Nov 6, 2020 · 0 comments
Assignees

Comments

@menelai
Copy link

menelai commented Nov 6, 2020

Does not work:

this.telegramService.sendDocument({
  chat_id: 100500,
  document: fs.createReadStream('error.txt') // <--- need to have Buffer here, tried a lot of ways to make it
}).subscribe()

Telegram API answers with code 400 without explanation.

Works:

import * as FormData from 'form-data';
...
const form = new FormData();
form.append('chat_id', chat_id);
form.append('document', Buffer.alloc(text.length, text), {filename: 'error.txt'});
form.submit(`https://api.telegram.org/bot${settings.telegramBot.key}/sendDocument`, function(err, response) {
 console.log(err, response);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants