Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
77095d0c
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
77095d0c
编写于
3月 22, 2022
作者:
W
wusongqing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added English js-apis-zlib.md
Signed-off-by:
N
wusongqing
<
wusongqing@huawei.com
>
上级
dd54dd65
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
56 addition
and
56 deletion
+56
-56
en/application-dev/reference/apis/js-apis-zlib.md
en/application-dev/reference/apis/js-apis-zlib.md
+56
-56
未找到文件。
en/application-dev/reference/apis/js-apis-zlib.md
浏览文件 @
77095d0c
# Zip
模块(JS端SDK接口
)
# Zip
Module (JavaScript SDK APIs
)
##
使用限制
无。
##
导入模块
##
Constraints
None
##
Modules to Import
import zlib from '@ohos.zlib'
## zlib.zipFile
zipFile(inFile:string, outFile:string, options: Options): Promise
<void>
;
压缩接口(Promise形式)。
Zips a file. This API uses a promise to return the result.
**
系统能力:**
SystemCapability.BundleManager.Zlib
**
System capability**
:
SystemCapability.BundleManager.Zlib
**
参数:
**
**
Parameters
**
|
名称 | 类型 | 必填 | 描述
|
|
Name | Type | Mandatory| Description
|
| ------- | ----------------------------------- | ---- | ------------------------------------------- |
| inFile | string |
是 | 指定压缩的文件夹路径或者文件路径
|
| outFile | string |
是 | 指定的压缩结果的文件路径(文件的扩展名zip)
|
| options |
[
Options
](
#options
对象可选参数说明
)
| 否 | 压缩的可选参数
|
| 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.
|
**
返回值:
**
**
Return value
**
|
类型 | 说明
|
|
Type | Description
|
| -------------- | ---------------------------------------------------- |
| Promise
\<
void> |
ERROR_CODE_OK:压缩成功 ERROR_CODE_ERRNO:压缩失败
|
| Promise
\<
void> |
Returns
**ERROR_CODE_OK**
if the operation is successful; returns
**ERROR_CODE_ERRNO**
otherwise.
|
**
示例1:
**
**
Example 1
**
```
javascript
//
【压缩文件 例子1】
//
Zip a file.
import
zlib
from
'
@ohos.zlib
'
var
inFile
=
"
/xxx/filename.xxx
"
;
var
outFile
=
"
/xxx/xxx.zip
"
;
...
...
@@ -49,10 +49,10 @@ zlib.zipFile(inFile, outFile, options).then((data) => {
```
**
示例2:
**
**
Example 2
**
```
//
【压缩文件夹 例子2】
//
Zip a folder.
import zlib from '@ohos.zlib'
var inFile = "/xxx/xxx";
var outFile = "/xxx/xxx.zip";
...
...
@@ -76,28 +76,28 @@ zlib.zipFile(inFile , unzipDir, options).then((data) => {
unzipFile(inFile:string, outFile:string, options: Options): Promise
<void>
;
解压文件,解压完成返回执行结果(Promise形式)。
Unzips a file. This API uses a promise to return the result.
**
系统能力:**
SystemCapability.BundleManager.Zlib
**
System capability**
:
SystemCapability.BundleManager.Zlib
**
参数:
**
**
Parameters
**
|
名称 | 类型 | 必填 | 描述
|
|
Name | Type | Mandatory| Description
|
| ------- | ----------------------------------- | ---- | ----------------------------------- |
| inFile | string |
是 | 指定解压的文件路径(文件扩展名zip)
|
| outFile | string |
是 | 指定的解压文件路径
|
| options |
[
Options
](
#options
对象可选参数说明
)
| 否 | 解压的可选参数
|
| inFile | string |
Yes | Path of the file to unzip. The file name extension is .zip.
|
| outFile | string |
Yes | Path of the unzipped file.
|
| options |
[
Options
](
#options
)
| No | Optional parameters for the unzip operation.
|
**
返回值:
**
**
Return value
**
|
类型 | 说明
|
|
Type | Description
|
| -------------- | ------------------------------------------------------------ |
| Promise
\<
void> |
ERROR_CODE_OK:解压成功 ERROR_CODE_ERRNO:解压失败返回执行结果。
|
| Promise
\<
void> |
Returns
**ERROR_CODE_OK**
if the operation is successful; returns
**ERROR_CODE_ERRNO**
otherwise.
|
**
示例:
**
**
Example
**
```
javascript
//
【解压例子1】
//
Unzip a file.
import
zlib
from
'
@ohos.zlib
'
var
inFile
=
"
/xx/xxx.zip
"
;
var
outFile
=
"
/xxx
"
;
...
...
@@ -119,43 +119,43 @@ zlib.unzipFile(inFile, outFile, options).then((data) => {
```
##
Options对象可选参数说明
##
options
|
参数
| |
|
Name
| |
| --------------------------- | ------------------------------------------------------------ |
| level?: CompressLeve |
[
参考zip.CompressLevel枚举定义
](
#zip.CompressLevel压缩等级可选参数说明
)
|
| memLevel?: MemLevel |
[
参考zip.MemLevel枚举定义
](
#zip.MemLevel可选参数说明
)
|
| strategy?: CompressStrategy |
[
参考zip.CompressStrategy枚举定义
](
#zip.CompressStrategy压缩策略可选参数说明
)
|
| level?: CompressLeve |
See
[
zip.CompressLevel
](
#zip.CompressLevel
)
.
|
| memLevel?: MemLevel |
See
[
zip.MemLevel
](
#zip.MemLevel
)
|
| strategy?: CompressStrategy |
See
[
zip.CompressStrategy
](
#zip.CompressStrategy
)
|
## zip.MemLevel
可选参数说明
## zip.MemLevel
| MEM_LEVEL_MIN |
zip 接口在压缩过程中最小使用内存
|
| MEM_LEVEL_MIN |
Minimum memory used by the
**zip**
API during compression.
|
| ----------------- | -------------------------------- |
| MEM_LEVEL_MAX |
zip 接口在压缩过程中最大使用内存
|
| MEM_LEVEL_DEFAULT |
zip 接口在压缩过程中默认使用内存
|
| MEM_LEVEL_MAX |
Maximum memory used by the
**zip**
API during compression.
|
| MEM_LEVEL_DEFAULT |
Default memory used by the
**zip**
API during compression.
|
##
zip.CompressLevel压缩等级可选参数说明
##
Zip.CompressLevel
|
参数 | 描述
|
|
Name | Description
|
| --------------------------------------- | ----------------- |
| COMPRESS_LEVEL_NO_COMPRESSION : 0 |
压缩率为0压缩等级
|
| COMPRESS_LEVEL_BEST_SPEED : 1 |
最佳速度压缩等级
|
| COMPRESS_LEVEL_BEST_COMPRESSION :9 |
最佳压缩等级
|
| COMPRESS_LEVEL_DEFAULT_COMPRESSION
:-1 | 默认压缩等级
|
| 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压缩策略可选参数说明
##
Zip.CompressStrategy
|
参数 | 描述
|
|
Name | Description
|
| -------------------------------------- | ------------------------ |
| COMPRESS_STRATEGY_DEFAULT_STRATEGY : 0 |
常规数据策略
|
| COMPRESS_STRATEGY_FILTERED : 1 |
过滤器产生的数据压缩策略
|
| COMPRESS_STRATEGY_HUFFMAN_ONLY : 2 |
霍夫曼编码格式压缩策略
|
| OMPRESS_STRATEGY_RLE : 3 |
游标编码压缩策略
|
| COMPRESS_STRATEGY_FIXED : 4 |
固定的压缩策略
|
| COMPRESS_STRATEGY_DEFAULT_STRATEGY : 0 |
Default compression strategy.
|
| COMPRESS_STRATEGY_FILTERED : 1 |
Filtered compression strategy.
|
| COMPRESS_STRATEGY_HUFFMAN_ONLY : 2 |
Huffman coding compression strategy.
|
| OMPRESS_STRATEGY_RLE : 3 |
RLE compression strategy.
|
| COMPRESS_STRATEGY_FIXED : 4 |
Fixed compression strategy.
|
## zip.ErrorCode
接口返回值参数说明
## zip.ErrorCode
|
参数 | 描述
|
|
Name | Description
|
| -------------------- | ------------ |
| ERROR_CODE_OK: 0 |
函数调用成功
|
| ERROR_CODE_ERRNO:- 1 |
函数调用失败
|
| 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录