Implemented URL query parsing for initial token /opa/?token=abcde
[src/app-framework-demo.git] / afb-client / bower_components / jszip / documentation / api_jszip / load.md
1 ---
2 title: "load(data [, options])"
3 layout: default
4 section: api
5 ---
6
7 __Description__ : Read an existing zip and merge the data in the current JSZip
8 object at the current folder level. This technique has some limitations, see
9 [here]({{site.baseurl}}/documentation/limitations.html).
10
11 __Arguments__
12
13 name               | type   | description
14 -------------------|--------|------------
15 data               | String/ArrayBuffer/Uint8Array/Buffer | the zip file
16 options            | object | the options to load the zip file
17
18 Content of `options` :
19
20 name                          | type    | default | description
21 ------------------------------|---------|---------|------------
22 options.base64                | boolean | false   | set to `true` if the data is base64 encoded, `false` for binary.
23 options.checkCRC32            | boolean | false   | set to `true` if the read data should be checked against its CRC32.
24 options.optimizedBinaryString | boolean | false   | set to true if (and only if) the input is a string and has already been prepared with a 0xFF mask.
25 options.createFolders      | boolean | false   | set to true to create folders in the file path automatically. Leaving it false will result in only virtual folders (i.e. folders that merely represent part of the file path) being created.
26
27 You shouldn't update the data given to this method : it is kept as it so any
28 update will impact the stored data.
29
30 Zip features supported by this method :
31
32 * Compression (<code>DEFLATE</code> supported)
33 * zip with data descriptor
34 * ZIP64
35 * UTF8 in file name, UTF8 in file content
36
37 Zip features not (yet) supported :
38
39 * password protected zip
40 * multi-volume zip
41
42 __Returns__ : The current JSZip object.
43
44 __Throws__ : An exception if the loaded data is not valid zip data or if it
45 uses features (multi volume, password protected, etc).
46
47 <!--
48 __Complexity__ : for k the number of entries in the zip file and n the length
49 of the data :
50
51 The default use case is **O(k)**.
52 If the data is in base64, we must first decode it : **O(k + n)**.
53 If the data is a string not in base64 and optimizedBinaryString is false, we
54 must apply the 0xFF mask : **O(k + n)**.
55 If checkCRC32 is true, it **adds** to the above complexity **O(n)** and the
56 complexity of the decompression algorithm.
57 -->
58
59 __Example__
60
61 ```js
62 var zip = new JSZip();
63 zip.load(zipDataFromXHR);
64 ```
65
66 ```js
67 require("fs").readFile("hello.zip", function (err, data) {
68   if (err) throw err;
69   var zip = new JSZip();
70   zip.load(data);
71 }
72 ```
73
74 Using sub folders :
75
76 ```js
77 var zip = new JSZip();
78 zip.folder("subfolder").load(data);
79 // the content of data will be loaded in subfolder/
80 ```
81