The **zlib** module provides APIs for file compression and decompression.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md)and[Stage Model](js-apis-application-context.md).|
| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md)or[Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the zipped file. The file name extension is .zip. |
| options | [Options](#options) | No | Optional parameters for the zip operation. |
...
...
@@ -36,59 +37,59 @@ Zips a file. This API uses a promise to return the result.
| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md) and[Stage Model](js-apis-application-context.md).|
| inFile | string | Yes | Path of the folder or file to unzip. For details about the path, see [FA Model](js-apis-Context.md) or[Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the unzipped file. |
| options | [Options](#options) | No | Optional parameters for the unzip operation. |
...
...
@@ -100,11 +101,11 @@ Unzips a file. This API uses a promise to return the result.
| inFile | string | Yes | Path of the folder or file to compress. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the compressed file. |
| AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. |
| inFile | string | Yes | Path of the folder or file to compress. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the compressed file. |
| inFile | string | Yes | Path of the file to decompress. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the decompressed file. |
| AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. |
| inFile | string | Yes | Path of the file to decompress. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the decompressed file. |
This error code is reported when the source file passed in the **compress** or **decompress** API is invalid.
**Possible Causes**
When the **compress** API is called, the file to compress does not exist. When the **decompress** API is called, the file to decompress does not exist.
**Procedure**
1. Check whether the source file exists.
2. Check whether the path of the source file exists and whether the path is the correct sandbox path.
## 900002 Invalid Destination File
**Error Message**
The input destination file is invalid.
**Description**
This error code is reported when the destination file passed in the **compress** or **decompress** API is invalid.
**Possible Causes**
1. When the **compress** API is called, the passed destination file path is invalid, for example, a non-exist sandbox path.
2. When the **decompress** API is called, the destination folder does not exist.
**Procedure**
1. Check whether the destination file path is correct. If not, enter the correct sandbox path.
2. Check whether the destination folder exists. If not, create the folder.