You need to sign in or sign up before continuing.
提交 569070d1 编写于 作者: G Gloria

Update docs against 16930

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 2038f7a0
...@@ -25,7 +25,7 @@ Zips a file. This API uses a promise to return the result. ...@@ -25,7 +25,7 @@ Zips a file. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the folder or file to zip. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).| | inFile | string | Yes | Path of the folder or file to zip. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the zipped file. The file name extension is .zip. | | outFile | string | Yes | Path of the zipped file. The file name extension is .zip. |
| options | [Options](#options) | Yes | Optional parameters for the zip operation. | | options | [Options](#options) | Yes | Optional parameters for the zip operation. |
...@@ -50,9 +50,9 @@ let options = { ...@@ -50,9 +50,9 @@ let options = {
}; };
zlib.zipFile(inFile, outFile, options).then((data) => { zlib.zipFile(inFile, outFile, options).then((data) => {
console.log('zipFile result is ' + JSON.Stringify(data)); console.log('zipFile result is ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log('error is ' + JSON.Stringify(err)); console.log('error is ' + JSON.stringify(err));
}); });
``` ```
...@@ -71,9 +71,9 @@ let options = { ...@@ -71,9 +71,9 @@ let options = {
}; };
zlib.zipFile(inFile , outFile, options).then((data) => { zlib.zipFile(inFile , outFile, options).then((data) => {
console.log('zipFile result is ' + JSON.Stringify(data)); console.log('zipFile result is ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.log('error is ' + JSON.Stringify(err)); console.log('error is ' + JSON.stringify(err));
}); });
``` ```
...@@ -91,7 +91,7 @@ Unzips a file. This API uses a promise to return the result. ...@@ -91,7 +91,7 @@ Unzips a file. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the file to unzip. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).| | inFile | string | Yes | Path of the file to unzip. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the unzipped file. | | outFile | string | Yes | Path of the unzipped file. |
| options | [Options](#options) | Yes | Optional parameters for the unzip operation. | | options | [Options](#options) | Yes | Optional parameters for the unzip operation. |
...@@ -116,9 +116,9 @@ let options = { ...@@ -116,9 +116,9 @@ let options = {
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
}; };
zlib.unzipFile(inFile, outFile, options).then((data) => { zlib.unzipFile(inFile, outFile, options).then((data) => {
console.log('unzipFile result is ' + JSON.Stringify(data)); console.log('unzipFile result is ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.log('error is ' + JSON.Stringify(err)); console.log('error is ' + JSON.stringify(err));
}) })
``` ```
...@@ -134,7 +134,7 @@ Compresses a file. This API uses an asynchronous callback to return the result. ...@@ -134,7 +134,7 @@ Compresses a file. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | | ----------------------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the folder or file to compress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).| | inFile | string | Yes | Path of the folder or file to compress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the compressed file. | | outFile | string | Yes | Path of the compressed file. |
| options | [Options](#options) | Yes | Compression parameters. | | options | [Options](#options) | Yes | Compression parameters. |
| 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. | | 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. |
...@@ -172,6 +172,8 @@ try { ...@@ -172,6 +172,8 @@ try {
} }
``` ```
## zlib.compressFile<sup>9+</sup>
compressFile(inFile: string, outFile: string, options: Options): Promise\<void>; compressFile(inFile: string, outFile: string, options: Options): Promise\<void>;
Compresses a file. This API uses a promise to return the result. Compresses a file. This API uses a promise to return the result.
...@@ -182,7 +184,7 @@ Compresses a file. This API uses a promise to return the result. ...@@ -182,7 +184,7 @@ Compresses a file. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the folder or file to compress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).| | inFile | string | Yes | Path of the folder or file to compress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the compressed file. | | outFile | string | Yes | Path of the compressed file. |
| options | [Options](#options) | Yes | Compression parameters. | | options | [Options](#options) | Yes | Compression parameters. |
...@@ -232,8 +234,8 @@ Decompresses a file. This API uses an asynchronous callback to return the result ...@@ -232,8 +234,8 @@ Decompresses a file. This API uses an asynchronous callback to return the result
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | | ----------------------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).| | inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the decompressed file. | | outFile | string | Yes | Path of the decompressed file. The path must exist in the system. Otherwise, the decompression fails. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| options | [Options](#options) | Yes | Decompression parameters. | | options | [Options](#options) | Yes | Decompression parameters. |
| 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. | | 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. |
...@@ -253,7 +255,7 @@ For details about the error codes, see [zlib Error Codes](../errorcodes/errorcod ...@@ -253,7 +255,7 @@ For details about the error codes, see [zlib Error Codes](../errorcodes/errorcod
// 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 the 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 the context.
import zlib from '@ohos.zlib'; import zlib from '@ohos.zlib';
let inFile = '/xx/xxx.zip'; let inFile = '/xx/xxx.zip';
let outFile = '/xxx'; let outFileDir = '/xxx';
let options = { let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
...@@ -261,7 +263,7 @@ let options = { ...@@ -261,7 +263,7 @@ let options = {
}; };
try { try {
zlib.decompressFile(inFile, outFile, options, (errData) => { zlib.decompressFile(inFile, outFileDir, options, (errData) => {
if (errData !== null) { if (errData !== null) {
console.log(`errData is errCode:${errData.code} message:${errData.message}`); console.log(`errData is errCode:${errData.code} message:${errData.message}`);
} }
...@@ -271,6 +273,8 @@ try { ...@@ -271,6 +273,8 @@ try {
} }
``` ```
## zlib.decompressFile<sup>9+</sup>
decompressFile(inFile: string, outFile: string, options: Options): Promise\<void>; decompressFile(inFile: string, outFile: string, options: Options): Promise\<void>;
Decompresses a file. This API uses a promise to return the result. Decompresses a file. This API uses a promise to return the result.
...@@ -281,8 +285,8 @@ Decompresses a file. This API uses a promise to return the result. ...@@ -281,8 +285,8 @@ Decompresses a file. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model] (js-apis-application-context.md).| | inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the decompressed file. | | outFile | string | Yes | Path of the decompressed file. The path must exist in the system. Otherwise, the decompression fails. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| options | [Options](#options) | Yes | Decompression parameters. | | options | [Options](#options) | Yes | Decompression parameters. |
**Error codes** **Error codes**
...@@ -299,7 +303,7 @@ For details about the error codes, see [zlib Error Codes](../errorcodes/errorcod ...@@ -299,7 +303,7 @@ For details about the error codes, see [zlib Error Codes](../errorcodes/errorcod
// 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 the 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 the context.
import zlib from '@ohos.zlib'; import zlib from '@ohos.zlib';
let inFile = '/xx/xxx.zip'; let inFile = '/xx/xxx.zip';
let outFile = '/xxx'; let outFileDir = '/xxx';
let options = { let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
...@@ -307,7 +311,7 @@ let options = { ...@@ -307,7 +311,7 @@ let options = {
}; };
try { try {
zlib.decompressFile(inFile, outFile, options).then((data) => { zlib.decompressFile(inFile, outFileDir, options).then((data) => {
console.info('decompressFile success'); console.info('decompressFile success');
}).catch((errData) => { }).catch((errData) => {
console.log(`errData is errCode:${errData.code} message:${errData.message}`); console.log(`errData is errCode:${errData.code} message:${errData.message}`);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册