diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2014-12-30 07:41:47 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2014-12-30 07:41:47 +0300 |
commit | 7a8790a8f0a7803be732b26eea34ae92e8ba92f5 (patch) | |
tree | 8147160c2b9cfdbd9dc4134342f56db26dc3351f /README.md | |
parent | ffcb0700e73a2fb21ff7d2a1bd3a19340823fcfa (diff) |
New API: Add file.getURL()
Fixes #217
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -311,6 +311,14 @@ Seed ratio for all torrents in the client. ### torrent api +#### `torrent.infoHash` + +Get the info hash of the torrent. + +#### `torrent.magnetURI` + +Get the magnet URI of the torrent. + #### `torrent.files[...]` An array of all files in the torrent. See the file section for more info on what methods @@ -415,6 +423,25 @@ You can pass `opts` to stream only a slice of a file. Both `start` and `end` are inclusive. +#### `file.getBlobURL(function callback (err, url) {})` + +Get a url which can be used in the browser to refer to the file. + +The file will be fetched from the network with highest priority, and `callback` will be +called when it is ready. `callback` must be specified and may be called with a an `Error` +or the blob url (`String`) when the file data is available and ready to be used. + +```js +file.getBlobURL(function (err, url) { + if (err) throw err + var a = document.createElement('a') + a.download = file.name + a.href = url + a.textContent = 'Download ' + file.name + body.appendChild(a) +}) +``` + ### Modules Most of the active development is happening inside of small npm modules which are used by WebTorrent. |