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 to save file to disk? #169

Open
jesusgn90 opened this issue Feb 8, 2017 · 5 comments
Open

How to save file to disk? #169

jesusgn90 opened this issue Feb 8, 2017 · 5 comments

Comments

@jesusgn90
Copy link

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
Copy link

you should probably use node's inbuilt fs

@jesusgn90
Copy link
Author

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

@swantzter
Copy link

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

@jesusgn90
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants