diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2014-12-30 08:58:38 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2014-12-30 08:58:38 +0300 |
commit | ff4257227b8c99f9c7506ec2e3b66bdcb045424f (patch) | |
tree | 6aaa48d98d5c1049c881ca6fc8cf8a47afca1234 /README.md | |
parent | 6e9fcfd03a38e1a4ab767c53ed7c82c254342109 (diff) |
remove concat-stream from example
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -100,7 +100,6 @@ standards (no plugins, just HTML5 and WebRTC)! It's easy to get started! ```js var WebTorrent = require('webtorrent') -var concat = require('concat-stream') var client = new WebTorrent() @@ -109,16 +108,17 @@ client.download(magnet_uri, function (torrent) { console.log('Torrent info hash:', torrent.infoHash) torrent.files.forEach(function (file) { - // Get the file data as a Buffer (Uint8Array typed array) - file.createReadStream().pipe(concat(function (buf) { + // Get a url for each file + file.getBlobURL(function (err, url) { + if (err) throw err - // Append a link to download the file + // Add a link to the page var a = document.createElement('a') a.download = file.name - a.href = URL.createObjectURL(new Blob([ buf ])) - a.textContent = 'download ' + file.name + a.href = url + a.textContent = 'Download ' + file.name document.body.appendChild(a) - })) + }) }) }) ``` @@ -438,7 +438,7 @@ file.getBlobURL(function (err, url) { a.download = file.name a.href = url a.textContent = 'Download ' + file.name - body.appendChild(a) + document.body.appendChild(a) }) ``` |