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

Avoiding that the complete file gets downloaded after call of file.createReadstream([opts]) #803

Closed
triangle42 opened this issue May 16, 2016 · 2 comments
Labels

Comments

@triangle42
Copy link

@triangle42 triangle42 commented May 16, 2016

  • WebTorrent version: 0.91.4

How can I avoid that the WebTorrent client downloads the entire file as fast as possible after I have called file.createReadstream([opts])? I want to configure the maximum amount of data that createReadstream buffers before I read the next chunk of data.

@feross feross added the question label May 17, 2016
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented May 17, 2016

Right now, there's no way to do this. Eventually, we're going to make the client switch to a rarest-first strategy (#375) once there's sufficient data buffered to satisfy all file.createReadStream() calls. But the plan is always going to be to download as fast as possible to make the best use of available network capacity (modulo throttling, once that gets implemented #163).

But in the meantime, you can accomplish what you want by calling createReadStream with opts.

You can pass opts to stream only a slice of a file.

{
  start: startByte,
  end: endByte
}

Both start and end are inclusive.

@feross feross closed this May 17, 2016
@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 4, 2018

This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue.

@lock lock bot locked as resolved and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.