Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
e5eb41b0
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
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看板
未验证
提交
e5eb41b0
编写于
11月 24, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 24, 2022
浏览文件
操作
浏览文件
下载
差异文件
!11797 【上传下载】示例代码修改
Merge pull request !11797 from wangdongqi/master
上级
a8ae4610
a5c90e07
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
0 deletion
+35
-0
zh-cn/application-dev/reference/apis/js-apis-request.md
zh-cn/application-dev/reference/apis/js-apis-request.md
+35
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-request.md
浏览文件 @
e5eb41b0
...
...
@@ -367,6 +367,7 @@ on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => vo
**示例:**
```
js
let
uploadTask
;
uploadTask
.
on
(
'
progress
'
,
function
callback
(
uploadedSize
,
totalSize
)
{
console
.
info
(
"
upload totalSize:
"
+
totalSize
+
"
uploadedSize:
"
+
uploadedSize
);
}
...
...
@@ -400,6 +401,7 @@ on(type: 'headerReceive', callback: (header: object) => void): void
**示例:**
```
js
let
uploadTask
;
uploadTask
.
on
(
'
headerReceive
'
,
function
callback
(
headers
){
console
.
info
(
"
upOnHeader headers:
"
+
JSON
.
stringify
(
headers
));
}
...
...
@@ -433,6 +435,7 @@ on(type: 'headerReceive', callback: (header: object) => void): void
**示例:**
```
js
let
uploadTask
;
uploadTask
.
on
(
'
complete
'
,
function
callback
(
taskStates
)
{
for
(
let
i
=
0
;
i
<
taskStates
.
length
;
i
++
)
{
console
.
info
(
"
upOnComplete taskState:
"
+
JSON
.
stringify
(
taskStates
[
i
]));
...
...
@@ -476,6 +479,7 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g
**示例:**
```
js
let
uploadTask
;
uploadTask
.
off
(
'
progress
'
,
function
callback
(
uploadedSize
,
totalSize
)
{
console
.
info
(
'
uploadedSize:
'
+
uploadedSize
,
'
totalSize:
'
+
totalSize
);
}
...
...
@@ -509,6 +513,7 @@ off(type: 'headerReceive', callback?: (header: object) => void): void
**示例:**
```
js
let
uploadTask
;
uploadTask
.
off
(
'
headerReceive
'
,
function
callback
(
headers
)
{
console
.
info
(
"
upOnHeader headers:
"
+
JSON
.
stringify
(
headers
));
}
...
...
@@ -541,6 +546,7 @@ off(type: 'headerReceive', callback?: (header: object) => void): void
**示例:**
```
js
let
uploadTask
;
uploadTask
.
off
(
'
complete
'
,
function
callback
(
taskStates
)
{
for
(
let
i
=
0
;
i
<
taskStates
.
length
;
i
++
)
{
console
.
info
(
"
upOnComplete taskState:
"
+
JSON
.
stringify
(
taskStates
[
i
]));
...
...
@@ -578,6 +584,7 @@ remove(): Promise<boolean>
**示例:**
```
js
let
uploadTask
;
uploadTask
.
remove
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Upload task removed successfully.
'
);
...
...
@@ -611,6 +618,7 @@ remove(callback: AsyncCallback<boolean>): void
**示例:**
```
js
let
uploadTask
;
uploadTask
.
remove
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to remove the upload task. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -644,6 +652,7 @@ delete(): Promise<boolean>
**示例:**
```
js
let
uploadTask
;
uploadTask
.
delete
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Upload task removed successfully.
'
);
...
...
@@ -675,6 +684,7 @@ delete(callback: AsyncCallback<boolean>): void
**示例:**
```
js
let
uploadTask
;
uploadTask
.
delete
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to remove the upload task. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1004,6 +1014,7 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) => vo
**示例:**
```
js
let
downloadTask
;
downloadTask
.
on
(
'
progress
'
,
function
download_callback
(
receivedSize
,
totalSize
)
{
console
.
info
(
"
download receivedSize:
"
+
receivedSize
+
"
totalSize:
"
+
totalSize
);
}
...
...
@@ -1065,6 +1076,7 @@ on(type: 'complete'|'pause'|'remove', callback:() => void): void
**示例:**
```
js
let
downloadTask
;
downloadTask
.
on
(
'
complete
'
,
function
callback
()
{
console
.
info
(
'
Download task completed.
'
);
}
...
...
@@ -1092,6 +1104,7 @@ off(type: 'complete'|'pause'|'remove', callback?:() => void): void
**示例:**
```
js
let
downloadTask
;
downloadTask
.
off
(
'
complete
'
,
function
callback
()
{
console
.
info
(
'
Download task completed.
'
);
}
...
...
@@ -1125,6 +1138,7 @@ on(type: 'fail', callback: (err: number) => void): void
**示例:**
```
js
let
downloadTask
;
downloadTask
.
on
(
'
fail
'
,
function
callBack
(
err
)
{
console
.
info
(
'
Download task failed. Cause:
'
+
err
);
}
...
...
@@ -1158,6 +1172,7 @@ off(type: 'fail', callback?: (err: number) => void): void
**示例:**
```
js
let
downloadTask
;
downloadTask
.
off
(
'
fail
'
,
function
callBack
(
err
)
{
console
.
info
(
'
Download task failed. Cause:
'
+
err
);
}
...
...
@@ -1186,6 +1201,7 @@ remove(): Promise<boolean>
**示例:**
```
js
let
downloadTask
;
downloadTask
.
remove
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Download task removed.
'
);
...
...
@@ -1219,6 +1235,7 @@ remove(callback: AsyncCallback<boolean>): void
**示例:**
```
js
let
downloadTask
;
downloadTask
.
remove
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to remove the download task.
'
);
...
...
@@ -1253,6 +1270,7 @@ query(): Promise<DownloadInfo>
**示例:**
```
js
let
downloadTask
;
downloadTask
.
query
().
then
((
downloadInfo
)
=>
{
console
.
info
(
'
Download task queried. Data:
'
+
JSON
.
stringify
(
downloadInfo
))
})
.
catch
((
err
)
=>
{
...
...
@@ -1282,6 +1300,7 @@ query(callback: AsyncCallback<DownloadInfo>): void
**示例:**
```
js
let
downloadTask
;
downloadTask
.
query
((
err
,
downloadInfo
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to query the download mimeType. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1313,6 +1332,7 @@ queryMimeType(): Promise<string>
**示例:**
```
js
let
downloadTask
;
downloadTask
.
queryMimeType
().
then
((
data
)
=>
{
console
.
info
(
'
Download task queried. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
...
...
@@ -1342,6 +1362,7 @@ queryMimeType(callback: AsyncCallback<string>): void;
**示例:**
```
js
let
downloadTask
;
downloadTask
.
queryMimeType
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to query the download mimeType. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1373,6 +1394,7 @@ pause(): Promise<void>
**示例:**
```
js
let
downloadTask
;
downloadTask
.
pause
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Download task paused.
'
);
...
...
@@ -1406,6 +1428,7 @@ pause(callback: AsyncCallback<void>): void
**示例:**
```
js
let
downloadTask
;
downloadTask
.
pause
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to pause the download task. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1441,6 +1464,7 @@ resume(): Promise<void>
**示例:**
```
js
let
downloadTask
;
downloadTask
.
resume
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Download task resumed.
'
)
...
...
@@ -1475,6 +1499,7 @@ resume(callback: AsyncCallback<void>): void
**示例:**
```
js
let
downloadTask
;
downloadTask
.
resume
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to resume the download task. Cause:
'
+
err
);
...
...
@@ -1508,6 +1533,7 @@ delete(): Promise<boolean>
**示例:**
```
js
let
downloadTask
;
downloadTask
.
delete
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Download task removed.
'
);
...
...
@@ -1539,6 +1565,7 @@ delete(callback: AsyncCallback<boolean>): void
**示例:**
```
js
let
downloadTask
;
downloadTask
.
delete
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to remove the download task.
'
);
...
...
@@ -1571,6 +1598,7 @@ getTaskInfo(): Promise<DownloadInfo>
**示例:**
```
js
let
downloadTask
;
downloadTask
.
getTaskInfo
().
then
((
downloadInfo
)
=>
{
console
.
info
(
'
Download task queried. Data:
'
+
JSON
.
stringify
(
downloadInfo
))
})
.
catch
((
err
)
=>
{
...
...
@@ -1598,6 +1626,7 @@ query(callback: AsyncCallback<DownloadInfo>): void
**示例:**
```
js
let
downloadTask
;
downloadTask
.
getTaskInfo
((
err
,
downloadInfo
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to query the download mimeType. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1627,6 +1656,7 @@ getTaskMimeType(): Promise<string>
**示例:**
```
js
let
downloadTask
;
downloadTask
.
getTaskMimeType
().
then
((
data
)
=>
{
console
.
info
(
'
Download task queried. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
...
...
@@ -1654,6 +1684,7 @@ getTaskMimeType(callback: AsyncCallback<string>): void;
**示例:**
```
js
let
downloadTask
;
downloadTask
.
getTaskMimeType
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to query the download mimeType. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1683,6 +1714,7 @@ suspend(): Promise<void>
**示例:**
```
js
let
downloadTask
;
downloadTask
.
suspend
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Download task paused.
'
);
...
...
@@ -1714,6 +1746,7 @@ suspend(callback: AsyncCallback<void>): void
**示例:**
```
js
let
downloadTask
;
downloadTask
.
suspend
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to pause the download task. Cause:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1747,6 +1780,7 @@ restore(): Promise<void>
**示例:**
```
js
let
downloadTask
;
downloadTask
.
restore
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Download task resumed.
'
)
...
...
@@ -1779,6 +1813,7 @@ restore(callback: AsyncCallback<void>): void
**示例:**
```
js
let
downloadTask
;
downloadTask
.
restore
((
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to resume the download task. Cause:
'
+
err
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录