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

!11797 【上传下载】示例代码修改

Merge pull request !11797 from wangdongqi/master
......@@ -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) =&gt; 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) =&gt; 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&lt;boolean&gt;
**示例:**
```js
let uploadTask;
uploadTask.remove().then((result) => {
if (result) {
console.info('Upload task removed successfully. ');
......@@ -611,6 +618,7 @@ remove(callback: AsyncCallback&lt;boolean&gt;): 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&lt;boolean&gt;
**示例:**
```js
let uploadTask;
uploadTask.delete().then((result) => {
if (result) {
console.info('Upload task removed successfully. ');
......@@ -675,6 +684,7 @@ delete(callback: AsyncCallback&lt;boolean&gt;): 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) =&gt; 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:() =&gt; 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?:() =&gt; 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) =&gt; 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) =&gt; void): void
**示例:**
```js
let downloadTask;
downloadTask.off('fail', function callBack(err) {
console.info('Download task failed. Cause:' + err);
}
......@@ -1186,6 +1201,7 @@ remove(): Promise&lt;boolean&gt;
**示例:**
```js
let downloadTask;
downloadTask.remove().then((result) => {
if (result) {
console.info('Download task removed.');
......@@ -1219,6 +1235,7 @@ remove(callback: AsyncCallback&lt;boolean&gt;): void
**示例:**
```js
let downloadTask;
downloadTask.remove((err, result)=>{
if(err) {
console.error('Failed to remove the download task.');
......@@ -1253,6 +1270,7 @@ query(): Promise&lt;DownloadInfo&gt;
**示例:**
```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&lt;DownloadInfo&gt;): 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&lt;string&gt;
**示例:**
```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&lt;string&gt;): 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&lt;void&gt;
**示例:**
```js
let downloadTask;
downloadTask.pause().then((result) => {
if (result) {
console.info('Download task paused. ');
......@@ -1406,6 +1428,7 @@ pause(callback: AsyncCallback&lt;void&gt;): 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&lt;void&gt;
**示例:**
```js
let downloadTask;
downloadTask.resume().then((result) => {
if (result) {
console.info('Download task resumed.')
......@@ -1475,6 +1499,7 @@ resume(callback: AsyncCallback&lt;void&gt;): 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&lt;boolean&gt;
**示例:**
```js
let downloadTask;
downloadTask.delete().then((result) => {
if (result) {
console.info('Download task removed.');
......@@ -1539,6 +1565,7 @@ delete(callback: AsyncCallback&lt;boolean&gt;): void
**示例:**
```js
let downloadTask;
downloadTask.delete((err, result)=>{
if(err) {
console.error('Failed to remove the download task.');
......@@ -1571,6 +1598,7 @@ getTaskInfo(): Promise&lt;DownloadInfo&gt;
**示例:**
```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&lt;DownloadInfo&gt;): 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&lt;string&gt;
**示例:**
```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&lt;string&gt;): 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&lt;void&gt;
**示例:**
```js
let downloadTask;
downloadTask.suspend().then((result) => {
if (result) {
console.info('Download task paused. ');
......@@ -1714,6 +1746,7 @@ suspend(callback: AsyncCallback&lt;void&gt;): 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&lt;void&gt;
**示例:**
```js
let downloadTask;
downloadTask.restore().then((result) => {
if (result) {
console.info('Download task resumed.')
......@@ -1779,6 +1813,7 @@ restore(callback: AsyncCallback&lt;void&gt;): 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.
先完成此消息的编辑!
想要评论请 注册