未验证 提交 e5be004b 编写于 作者: O openharmony_ci 提交者: Gitee

!6323 翻译完成:5892 md文档扫描缺陷修改

Merge pull request !6323 from wusongqing/TR5892
# Zip Module (JavaScript SDK APIs)
# Zip
> **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.
## Constraints
None
## Modules to Import
```javascript
......@@ -7,8 +14,7 @@ import zlib from '@ohos.zlib';
```
## zlib.zipFile
zipFile(inFile:string, outFile:string, options: Options): Promise\<void>
zipFile(inFile:string, outFile:string, options: Options): Promise&lt;void&gt;
Zips a file. This API uses a promise to return the result.
......@@ -16,11 +22,11 @@ Zips a file. This API uses a promise to return the result.
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ----------------------------------- | ---- | ------------------------------------------- |
| inFile | string | Yes | Path of the folder or file to zip. |
| outFile | string | Yes | Path of the zipped file. The file name extension is .zip.|
| options | [Options](#options)| No | Optional parameters for the zip operation. |
| Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ |
| 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).|
| outFile | string | Yes | Path of the zipped file. The file name extension is .zip. |
| options | [Options](#options) | No | Optional parameters for the zip operation. |
**Return value**
......@@ -72,7 +78,7 @@ zlib.zipFile(inFile , outFile, options).then((data) => {
## zlib.unzipFile
unzipFile(inFile:string, outFile:string, options: Options): Promise\<void>
unzipFile(inFile:string, outFile:string, options: Options): Promise&lt;void&gt;
Unzips a file. This API uses a promise to return the result.
......@@ -80,11 +86,11 @@ Unzips a file. This API uses a promise to return the result.
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ----------------------------------- | ---- | ----------------------------------- |
| inFile | string | Yes | Path of the .zip file to unzip.|
| outFile | string | Yes | Path of the unzipped file. |
| options | [Options](#options)| No | Optional parameters for the unzip operation. |
| Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ |
| 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).|
| outFile | string | Yes | Path of the unzipped file. |
| options | [Options](#options) | No | Optional parameters for the unzip operation. |
**Return value**
......@@ -115,42 +121,52 @@ zlib.unzipFile(inFile, outFile, options).then((data) => {
## Options
| Name | Description |
| --------------------------- | ------------------------------------------------------------ |
| level?: CompressLeve | See [zip.CompressLevel](#zipcompresslevel).|
| memLevel?: MemLevel | See [zip.MemLevel](#zipmemlevel). |
| strategy?: CompressStrategy | See [zip.CompressStrategy](#zipcompressstrategy).|
**System capability**: SystemCapability.BundleManager.Zlib
| Name | Type | Mandatory| Description |
| -------- | ---------------- | ---- | --------------------------------------------------------- |
| level | CompressLeve | No | See [zip.CompressLevel](#zipcompresslevel). |
| memLevel | MemLevel | No | See [zip.MemLevel](#zipmemlevel). |
| strategy | CompressStrategy | No | See [zip.CompressStrategy](#zipcompressstrategy).|
## zip.MemLevel
| Name | Description |
| ----------------- | -------------------------------- |
| MEM_LEVEL_MIN | Minimum memory used by the **zip** API during compression.|
| MEM_LEVEL_MAX | Maximum memory used by the **zip** API during compression.|
| MEM_LEVEL_DEFAULT | Default memory used by the **zip** API during compression.|
**System capability**: SystemCapability.BundleManager.Zlib
## Zip.CompressLevel
| Name | Value | Description |
| ----------------- | ---- | -------------------------------- |
| MEM_LEVEL_MIN | 1 | Minimum memory used by the **zip** API during compression.|
| MEM_LEVEL_MIN | 9 | Maximum memory used by the **zip** API during compression.|
| MEM_LEVEL_DEFAULT | 8 | Default memory used by the **zip** API during compression.|
| Name | Description |
| --------------------------------------- | ----------------- |
| COMPRESS_LEVEL_NO_COMPRESSION: 0 | Compress level 0 that indicates uncompressed.|
| COMPRESS_LEVEL_BEST_SPEED: 1 | Compression level 1 that gives the best speed. |
| COMPRESS_LEVEL_BEST_COMPRESSION: 9 | Compression level 9 that gives the best compression. |
| COMPRESS_LEVEL_DEFAULT_COMPRESSION: -1| Default compression level. |
## zip.CompressLevel
## Zip.CompressStrategy
**System capability**: SystemCapability.BundleManager.Zlib
| Name | Description |
| -------------------------------------- | ------------------------ |
| COMPRESS_STRATEGY_DEFAULT_STRATEGY: 0 | Default compression strategy. |
| COMPRESS_STRATEGY_FILTERED: 1 | Filtered compression strategy.|
| COMPRESS_STRATEGY_HUFFMAN_ONLY: 2 | Huffman coding compression strategy. |
| COMPRESS_STRATEGY_RLE: 3 | RLE compression strategy. |
| COMPRESS_STRATEGY_FIXED: 4 | Fixed compression strategy. |
| Name | Value | Description |
| ---------------------------------- | ---- | ----------------- |
| COMPRESS_LEVEL_NO_COMPRESSION | 0 | Compress level 0 that indicates uncompressed.|
| COMPRESS_LEVEL_BEST_SPEED | 1 | Compression level 1 that gives the best speed. |
| COMPRESS_LEVEL_BEST_COMPRESSION | 9 | Compression level 9 that gives the best compression. |
| COMPRESS_LEVEL_DEFAULT_COMPRESSION | -1 | Default compression level. |
## zip.CompressStrategy
**System capability**: SystemCapability.BundleManager.Zlib
| Name | Value | Description |
| ---------------------------------- | ---- | ------------------------ |
| COMPRESS_STRATEGY_DEFAULT_STRATEGY | 0 | Default compression strategy. |
| COMPRESS_STRATEGY_FILTERED | 1 | Filtered compression strategy.|
| COMPRESS_STRATEGY_HUFFMAN_ONLY | 2 | Huffman coding compression strategy. |
| COMPRESS_STRATEGY_RLE | 3 | RLE compression strategy. |
| COMPRESS_STRATEGY_FIXED | 4 | Fixed compression strategy. |
## zip.ErrorCode
| Name | Description |
| -------------------- | ------------ |
| ERROR_CODE_OK: 0 | The API is successfully called.|
| ERROR_CODE_ERRNO: -1| Failed to call the API.|
**System capability**: SystemCapability.BundleManager.Zlib
| Name | Value | Description |
| ---------------- | ---- | ------------ |
| ERROR_CODE_OK | 0 | The API is successfully called.|
| ERROR_CODE_ERRNO | -1 | Failed to call the API.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册