Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upIs it possible to pipe the torrent files to a spawn while downloading at the same time? #608
Comments
This comment has been minimized.
This comment has been minimized.
|
Yep that should work just fine. You can get a torrent file as a stream like this: var WebTorrent = require('webtorrent')
var client = new WebTorrent()
client.add(magnet_uri, function (torrent) {
var file = torrent.files[0] // get the file you want to upload
file.createReadStream().pipe(/* your child process stdin */)
}) |
This comment has been minimized.
This comment has been minimized.
|
@feross Yes, but it still writes to /tmp/webtorrent would it work if I make the path to /dev/null? Thanks. |
This comment has been minimized.
This comment has been minimized.
|
@van-nguyen The file data needs to be available somewhere for the proper functioning of the torrent protocol, i.e. peers may ask for pieces of the file, so your client can't throw them away until you remove the torrent and leave the swarm. That's why passing Instead, you can use an in-memory storage (instead of the default filesystem storage). Be warned this will keep the full file in RAM until you remove the torrent from the client, but otherwise should work fine. Here's how to do this: var MemoryChunkStore = require('memory-chunk-store')
var WebTorrent = require('webtorrent')
var client = new WebTorrent()
client.add(magnet_uri, { store: MemoryChunkStore }, function (torrent) {
// ...
})See the |
This comment has been minimized.
This comment has been minimized.
|
This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue. |
Seems like a pretty nice library, was wondering if the following scenario is possible, the use case is not having to save the files physically to a disk, which would allow uploading directly to a remote server.
Would something like this be feasible?