diff --git a/en/application-dev/reference/apis/js-apis-zlib.md b/en/application-dev/reference/apis/js-apis-zlib.md index 967def0ecbdfda71fe88bc55ac02e6d395046a00..bc2a9504185453888cf8ba53416f38a44519c5a2 100644 --- a/en/application-dev/reference/apis/js-apis-zlib.md +++ b/en/application-dev/reference/apis/js-apis-zlib.md @@ -26,8 +26,8 @@ Zips a file. This API uses a promise to return the result. | 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) 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. | +| outFile | string | Yes | Path of the zipped file. The file name extension is .zip. | +| options | [Options](#options) | Yes | Optional parameters for the zip operation. | **Return value** @@ -90,8 +90,8 @@ Unzips a file. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | ------- | ------------------- | ---- | ------------------------------------------------------------ | | 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. | +| outFile | string | Yes | Path of the unzipped file. | +| options | [Options](#options) | Yes | Optional parameters for the unzip operation. | **Return value** @@ -138,17 +138,17 @@ Compresses a file. This API uses an asynchronous callback to return the result. **Error codes** +For details about the error codes, see [zlib Error Codes](../errorcodes/errorcode-zlib.md). | ID| Error Message | -| ------ | -------------------------------------- | -| 401 | wrong param type | -| 900001 | The Input source file is invalid. | -| 900002 | The Input destination file is invalid. | +| -------- | --------------------------------------| +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | **Example** ```typescript // Compress a file. -// The path used in the code must be the application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context. +// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context. import zlib from '@ohos.zlib'; let inFile = '/xxx/filename.xxx'; let outFile = '/xxx/xxx.zip'; @@ -160,12 +160,12 @@ let options = { try { zlib.compressFile(inFile, outFile, options, (errData) => { - if (erData !== null) { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + if (errData !== null) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); } }) } catch(errData) { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + console.log(`errData is errCode:${errData.code} message:${errData.message}`); } ``` @@ -185,15 +185,16 @@ Compresses a file. This API uses a promise to return the result. **Error codes** +For details about the error codes, see [zlib Error Codes](../errorcodes/errorcode-zlib.md). + | ID| Error Message | -| ------ | -------------------------------------- | -| 401 | wrong param type | -| 900001 | The Input source file is invalid. | -| 900002 | The Input destination file is invalid. | +| -------- | ------------------------------------- | +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | ```typescript // Compress a file. -// The path used in the code must be the application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context. +// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context. import zlib from '@ohos.zlib'; let inFile = '/xxx/filename.xxx'; let outFile = '/xxx/xxx.zip'; @@ -207,10 +208,10 @@ try { zlib.compressFile(inFile, outFile, options).then((data) => { console.info('compressFile success'); }).catch((errData) => { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + console.log(`errData is errCode:${errData.code} message:${errData.message}`); }) } catch(errData) { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + console.log(`errData is errCode:${errData.code} message:${errData.message}`); } ``` @@ -235,11 +236,12 @@ Decompresses a file. This API uses an asynchronous callback to return the result **Error codes** -| ID| Error Message | -| ------ | -------------------------------------- | -| 401 | wrong param type | -| 900001 | The Input source file is invalid. | -| 900002 | The Input destination file is invalid. | +For details about the error codes, see [zlib Error Codes](../errorcodes/errorcode-zlib.md). + +| ID| Error Message +| -------- | --------------------------------------| +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | **Example** @@ -257,12 +259,12 @@ let options = { try { zlib.decompressFile(inFile, outFile, options, (errData) => { - if (erData !== null) { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + if (errData !== null) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); } }) } catch(errData) { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + console.log(`errData is errCode:${errData.code} message:${errData.message}`); } ``` @@ -282,15 +284,16 @@ Decompress a file. This API uses a promise to return the result. **Error codes** +For details about the error codes, see [zlib Error Codes](../errorcodes/errorcode-zlib.md). + | ID| Error Message | -| ------ | -------------------------------------- | -| 401 | wrong param type | +| ------ | ------------------------------------- | | 900001 | The Input source file is invalid. | | 900002 | The Input destination file is invalid. | ```typescript // Decompress a file. -// The path used in the code must be the application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context. +// The path used in the code must be an application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context. import zlib from '@ohos.zlib'; let inFile = '/xx/xxx.zip'; let outFile = '/xxx'; @@ -301,13 +304,13 @@ let options = { }; try { - zlib.deCompressFile(inFile, outFile, options).then((data) => { - console.info('deCompressFile success'); + zlib.decompressFile(inFile, outFile, options).then((data) => { + console.info('decompressFile success'); }).catch((errData) => { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + console.log(`errData is errCode:${errData.code} message:${errData.message}`); }) } catch(errData) { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + console.log(`errData is errCode:${errData.code} message:${errData.message}`); } ``` @@ -315,11 +318,11 @@ try { **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).| +| Name | Type | Readable| Writable| Description | +| -------- | ---------------- | ---- | ---- | ---------------------------------------------------------- | +| level | CompressLevel | Yes | No | See [zip.CompressLevel](#zipcompresslevel). | +| memLevel | MemLevel | Yes | No | See [zip.MemLevel](#zipmemlevel). | +| strategy | CompressStrategy | Yes | No | See [zip.CompressStrategy](#zipcompressstrategy).| ## zip.CompressLevel diff --git a/en/application-dev/reference/errorcodes/errorcode-zlib.md b/en/application-dev/reference/errorcodes/errorcode-zlib.md index ea2b330abea46f7f9a9eebfff7e427cf57197cc2..1e5fbb46a15294207dd4c1e2c10e8de98bbdc93f 100644 --- a/en/application-dev/reference/errorcodes/errorcode-zlib.md +++ b/en/application-dev/reference/errorcodes/errorcode-zlib.md @@ -14,10 +14,10 @@ This error code is reported when the source file passed in the **compress** or * 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** +**Solution** -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. +1. Make sure the source file exists. +2. Make sure the path of the source file exists and the path is the correct sandbox path. ## 900002 Invalid Destination File @@ -34,7 +34,7 @@ This error code is reported when the destination file passed in the **compress** 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** +**Solution** 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.