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>2015-01-04 05:45:16 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-01-04 05:45:16 +0300
commit8fd9cb092ae5899767c1ae7bab2be872c9543e35 (patch)
tree6f0cb39e4a1ee9971bca5430a039f32a13755787 /README.md
parent1aee189a736c0d1c9d8341ee3a4ec599c6cc1af4 (diff)
Add file.getBuffer() API
Diffstat (limited to 'README.md')
-rw-r--r--README.md19
1 files changed, 17 insertions, 2 deletions
diff --git a/README.md b/README.md
index 7c5a1d2..b9ac698 100644
--- a/README.md
+++ b/README.md
@@ -428,13 +428,28 @@ You can pass `opts` to stream only a slice of a file.
Both `start` and `end` are inclusive.
+#### `file.getBuffer(function callback (err, url) {})`
+
+Get the file contents as a `Buffer`.
+
+The file will be fetched from the network with highest priority, and `callback` will be
+called once the file is ready. `callback` must be specified, and will be called with a an
+`Error` (or `null`) and the file contents as a `Buffer`.
+
+```js
+file.getBuffer(function (err, buffer) {
+ if (err) throw err
+ console.log(buffer) // <Buffer 00 98 00 01 01 00 00 00 50 ae 07 04 01 00 00 00 0a 00 00 00 00 00 00 00 78 ae 07 04 01 00 00 00 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...>
+})
+```
+
#### `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.
+called once the file is ready. `callback` must be specified, and will be called with a an
+`Error` (or `null`) and the Blob URL (`String`).
```js
file.getBlobURL(function (err, url) {