Naltox / telegram-node-bot

Node module for creating Telegram bots.
MIT License
720 stars 144 forks source link

How to save file to disk? #169

Open jesusgn90 opened 7 years ago

jesusgn90 commented 7 years ago

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
            });
        }
swantzter commented 7 years ago

you should probably use node's inbuilt fs

jesusgn90 commented 7 years ago

I know fs of course but how to pipe File type object in my code to fs?

swantzter commented 7 years ago

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/ the file must be no larger than 20mb. see https://core.telegram.org/bots/api#getfile

jesusgn90 commented 7 years ago

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

jesusgn90 commented 7 years ago

Help me with this please I like this module I don't want to change it!