From 7a8790a8f0a7803be732b26eea34ae92e8ba92f5 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Mon, 29 Dec 2014 20:41:47 -0800 Subject: New API: Add file.getURL() Fixes #217 --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index f4ceed1..31713ff 100644 --- a/README.md +++ b/README.md @@ -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. -- cgit v1.2.3