mirror of
https://gitlab.com/skysthelimit.dev/selenite.git
synced 2025-06-17 19:12:07 -05:00
2.6 KiB
2.6 KiB
title, layout, section
title | layout | section |
---|---|---|
generate(options) | default | api |
Description : Generates the complete zip file.
Arguments
name | type | default | description |
---|---|---|---|
options | object | the options to generate the zip file : | |
options.base64 | boolean | false | deprecated, use type instead. If type is not used, set to false to get the result as a raw byte string, true to encode it as base64. |
options.compression | string | STORE (no compression) |
the default file compression method to use. Available methods are STORE and DEFLATE . You can also provide your own compression method. |
options.type | string | base64 |
The type of zip to return, see below for the other types. |
options.comment | string | The comment to use for the zip file. |
Possible values for type
:
base64
(default) : the result will be a string, the binary in a base64 form.string
: the result will be a string in "binary" form, using 1 byte per char (2 bytes).uint8array
: the result will be a Uint8Array containing the zip. This requires a compatible browser.arraybuffer
: the result will be a ArrayBuffer containing the zip. This requires a compatible browser.blob
: the result will be a Blob containing the zip. This requires a compatible browser.nodebuffer
: the result will be a nodejs Buffer containing the zip. This requires nodejs.
Note : when using type = "uint8array", "arraybuffer" or "blob", be sure to
check if the browser supports it (you can use JSZip.support
).
Note for the comment
option : the zip format has no flag or field to give the
encoding of this field and JSZip will use UTF-8. With non ASCII characters you
might get encoding issues if the file archiver doesn't use UTF-8 to decode the
comment.
If not set, JSZip will use the field comment
on its options
.
Returns : The generated zip file.
Throws : An exception if the asked type
is not available in the browser,
see JSZip.support.
Example
var content = zip.generate({type:"blob"});
// see FileSaver.js
saveAs(content, "hello.zip");
var content = zip.generate({type:"base64"});
location.href="data:application/zip;base64,"+content;
var content = zip.generate({type:"nodebuffer"});
require("fs").writeFile("hello.zip", content, function(err){/*...*/});