Skip to content
Browse files

Merge pull request #289 from dduponchel/stream_documentation

Include nodejs stream in the file() documentation.
2 parents 4e785ff + b126039 commit 2faadbe89a1d1a343d67ebcf12a23993afbe64d2 @dduponchel dduponchel committed Apr 30, 2016
Showing with 12 additions and 1 deletion.
  1. +8 −1 documentation/api_jszip/file_data.md
  2. +4 −0 documentation/howto/read_zip.md
View
9 documentation/api_jszip/file_data.md
@@ -11,7 +11,7 @@ __Arguments__
name | type | description
--------------------|---------|------------
name | string | the name of the file. You can specify folders in the name : the folder separator is a forward slash ("/").
-data | String/ArrayBuffer/Uint8Array/Buffer/Blob/Promise | the content of the file.
+data | String/ArrayBuffer/Uint8Array/Buffer/Blob/Promise/Nodejs stream | the content of the file.
options | object | the options.
Content of `options` :
@@ -48,6 +48,13 @@ __About `dir`__ :
If `dir` is true or if a permission says it's a folder, this entry be flagged
as a folder and the content will be ignored.
+__About nodejs stream__:
+
+A stream can't be restarted: if it is used once, it can't be used again (
+by [generateAsync()]({{site.baseurl}}/documentation/api_jszip/generate_async.html)
+or by [ZipObject methods]({{site.baseurl}}/documentation/api_zipobject.html)).
+In that case, the promise/stream (depending on the method called) will get
+an error.
__Returns__ : The current JSZip object, for chaining.
View
4 documentation/howto/read_zip.md
@@ -73,6 +73,10 @@ fs.readFile("picture.png", function(err, data) {
var zip = new JSZip();
zip.file("picture.png", data);
});
+
+// read a file as a stream and add it to a zip
+var stream = fs.createReadStream("picture.png");
+zip.file("picture.png", stream);
```
#### Remote file

0 comments on commit 2faadbe

Please sign in to comment.
Something went wrong with that request. Please try again.