telegram-node-bot
telegram-node-bot copied to clipboard
How to save file to disk?
Here is my code:
let document = $.message.document;
(document) ? $.sendMessage('Greate i\'m going to convert it...') : $.sendMessage('Please send me a document...');
if(document) {
$.api.getFile(document.fileId).then(function(data){
// HOW I SAVE THIS FILE TO HARD DISK OR SOMEWHERE ELSE
});
}
you should probably use node's inbuilt fs
I know fs of course but how to pipe File type object in my code to fs?
hmm, yeah I investigated a bit, and I initially thought data
would contain the file's data in some way... it apparently didn't. however data.file_path
can be used to download the file from https://api.telegram.org/file/bot
Yes I know it too but I think the path it's wrong the URL sends error if you try, let's try by yourself please
Help me with this please I like this module I don't want to change it!