telegram-node-bot icon indicating copy to clipboard operation
telegram-node-bot copied to clipboard

How to save file to disk?

Open jesusgn90 opened this issue 8 years ago • 5 comments

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
            });
        }

jesusgn90 avatar Feb 08 '17 13:02 jesusgn90

you should probably use node's inbuilt fs

swantzter avatar Feb 11 '17 15:02 swantzter

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

jesusgn90 avatar Feb 11 '17 15:02 jesusgn90

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

swantzter avatar Feb 11 '17 16:02 swantzter

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 avatar Feb 11 '17 17:02 jesusgn90

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

jesusgn90 avatar Feb 22 '17 23:02 jesusgn90