You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BitTorrent backed streaming blob store, both read and write supported.
npm install torrent-blob-store
Usage
vartorrents=require('torrent-blob-store')varstore=torrents()// create a read stream to some star trek fan fictionvarrs=store.createReadStream({link: 'magnet:?xt=urn:btih:ef330b39f4801d25b4245212e75a38634bfc856e',index: 1// get the file at index 1})rs.on('data',function(data){console.log('received:',data)// data received from peers})rs.on('end',function(){console.log('(no more data)')})
You can pass in the same options in the blob store constructor as in torrent-stream.
All read streams needs link to be set. Currently only magnet links are supported
Write
Torrent-blob store also lets you createWriteStream and provides you with a magnet link.
varTracker=require('bittorrent-tracker').Servervarblob=require('torrent-blob-store')varserver=newTracker({http: true})varconcat=require('concat-stream')server.listen(0,'127.0.0.1',function(){varstore=blob({trackers: ['https://localhost:'+server.http.address().port,'udp://localhost:'+server.udp.address().port]})varw=store.createWriteStream(function(err,res){console.log(res.link)// will print out the magnet linkstore.createReadStream(res.link).pipe(concat(function(body){console.log(body.toString())// will print 'whatever'}))})w.end('whatever')})