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

Pause, resume and abort #42

Open
theIYD opened this issue Apr 25, 2018 · 2 comments
Open

Pause, resume and abort #42

theIYD opened this issue Apr 25, 2018 · 2 comments

Comments

@theIYD
Copy link

theIYD commented Apr 25, 2018

While downloading, i want to allow the user to pause() the stream whenever they want and resume() it as per their needs. Also they would also want to abort() or stop the stream.

How do i do it ?

@hgouveia
Copy link

hgouveia commented Apr 26, 2018

in order to pause/resume you will need a refernce to request

const require = require('request');
const progress= require('request-progress');

const url = '';
const filePath = '';

const _request = request(url);
const _progress = progress(_request)
                                .on('progress', (stats) => {})
                                .on('error', (err) => {})
                                .on('end', () => {})
                                .pipe(fs.createWriteStream(filePath));

_request.pause();
_request.resume();

@theIYD
Copy link
Author

theIYD commented Apr 26, 2018

Thank you so much ! Can i abort/stop the request ?

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