Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2014-12-30 08:58:38 +0300
committerFeross Aboukhadijeh <feross@feross.org>2014-12-30 08:58:38 +0300
commitff4257227b8c99f9c7506ec2e3b66bdcb045424f (patch)
tree6aaa48d98d5c1049c881ca6fc8cf8a47afca1234 /README.md
parent6e9fcfd03a38e1a4ab767c53ed7c82c254342109 (diff)
remove concat-stream from example
Diffstat (limited to 'README.md')
-rw-r--r--README.md16
1 files changed, 8 insertions, 8 deletions
diff --git a/README.md b/README.md
index 31713ff..db7828b 100644
--- a/README.md
+++ b/README.md
@@ -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)
})
```