提交 edef43b8 编写于 作者: E ester.zhou

Update docs (13845)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 8bc22295
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
The **request** module provides applications with basic upload, download, and background transmission agent capabilities. The **request** module provides applications with basic upload, download, and background transmission agent capabilities.
> **NOTE**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -77,7 +78,7 @@ The table below lists the causes of download pause that may be returned by [getT ...@@ -77,7 +78,7 @@ The table below lists the causes of download pause that may be returned by [getT
| PAUSED_QUEUED_FOR_WIFI<sup>7+</sup> | number | 0 | Download paused and queuing for a WLAN connection, because the file size exceeds the maximum value allowed by a mobile network session.| | PAUSED_QUEUED_FOR_WIFI<sup>7+</sup> | number | 0 | Download paused and queuing for a WLAN connection, because the file size exceeds the maximum value allowed by a mobile network session.|
| PAUSED_WAITING_FOR_NETWORK<sup>7+</sup> | number | 1 | Download paused due to a network connection problem, for example, network disconnection.| | PAUSED_WAITING_FOR_NETWORK<sup>7+</sup> | number | 1 | Download paused due to a network connection problem, for example, network disconnection.|
| PAUSED_WAITING_TO_RETRY<sup>7+</sup> | number | 2 | Download paused and then retried.| | PAUSED_WAITING_TO_RETRY<sup>7+</sup> | number | 2 | Download paused and then retried.|
| PAUSED_BY_USER<sup>9+</sup> | number | 3 | The user paused the session. | | PAUSED_BY_USER<sup>9+</sup> | number | 3 | The user paused the session.|
| PAUSED_UNKNOWN<sup>7+</sup> | number | 4 | Download paused due to unknown reasons.| | PAUSED_UNKNOWN<sup>7+</sup> | number | 4 | Download paused due to unknown reasons.|
### Download Task Status Codes ### Download Task Status Codes
...@@ -378,6 +379,8 @@ Uploads files. This API uses an asynchronous callback to return the result. ...@@ -378,6 +379,8 @@ Uploads files. This API uses an asynchronous callback to return the result.
Implements file uploads. Before using any APIs of this class, you must obtain an **UploadTask** object through [request.uploadFile<sup>9+</sup>](#requestuploadfile9) in promise mode or [request.uploadFile<sup>9+</sup>](#requestuploadfile9-1) in callback mode. Implements file uploads. Before using any APIs of this class, you must obtain an **UploadTask** object through [request.uploadFile<sup>9+</sup>](#requestuploadfile9) in promise mode or [request.uploadFile<sup>9+</sup>](#requestuploadfile9-1) in callback mode.
### on('progress') ### on('progress')
on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; void): void on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; void): void
...@@ -399,8 +402,8 @@ Parameters of the callback function ...@@ -399,8 +402,8 @@ Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes| Size of the uploaded files, in bytes. | | uploadedSize | number | Yes| Size of the uploaded files, in bytes.|
| totalSize | number | Yes| Total size of the files to upload, in bytes. | | totalSize | number | Yes| Total size of the files to upload, in bytes.|
**Example** **Example**
...@@ -504,12 +507,12 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -504,12 +507,12 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).|
| callback | function | No| Callback for the upload progress event.| | callback | function | No| Callback for the upload progress event.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes| Size of the uploaded files, in bytes. | | uploadedSize | number | Yes| Size of the uploaded files, in bytes.|
| totalSize | number | Yes| Total size of the files to upload, in bytes. | | totalSize | number | Yes| Total size of the files to upload, in bytes.|
**Example** **Example**
...@@ -764,7 +767,7 @@ Removes this upload task. This API uses an asynchronous callback to return the r ...@@ -764,7 +767,7 @@ Removes this upload task. This API uses an asynchronous callback to return the r
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| filename | string | Yes| File name in the header when **multipart** is used.| | filename | string | Yes| File name in the header when **multipart** is used.|
| name | string | Yes| Name of a form item when **multipart** is used. The default value is **file**.| | name | string | Yes| Name of a form item when **multipart** is used. The default value is **file**.|
| uri | string | Yes| Local path for storing files.<br>The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. Below are examples:<br>dataability:///com.domainname.dataability.persondata/person/10/file.txt<br><br>internal://cache/path/to/file.txt | | uri | string | Yes| Local path for storing files.<br>Only the **internal** protocol type is supported. In the value, **internal://cache/** is mandatory. Example:<br>internal://cache/path/to/file.txt |
| type | string | Yes| Type of the file content. By default, the type is obtained based on the extension of the file name or URI.| | type | string | Yes| Type of the file content. By default, the type is obtained based on the extension of the file name or URI.|
...@@ -1047,12 +1050,12 @@ Subscribes to a download event. This API uses an asynchronous callback to return ...@@ -1047,12 +1050,12 @@ Subscribes to a download event. This API uses an asynchronous callback to return
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).| | type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).|
| callback | function | Yes| Callback for the download progress event.| | callback | function | Yes| Callback for the download progress event.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| receivedSize | number | Yes| Size of the downloaded files, in bytes. | | receivedSize | number | Yes| Size of the downloaded files, in bytes.|
| totalSize | number | Yes| Total size of the files to download, in bytes. | | totalSize | number | Yes| Total size of the files to download, in bytes.|
**Example** **Example**
...@@ -1085,8 +1088,8 @@ Parameters of the callback function ...@@ -1085,8 +1088,8 @@ Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| receivedSize | number | Yes| Size of the downloaded files, in bytes. | | receivedSize | number | Yes| Size of the downloaded files, in bytes.|
| totalSize | number | Yes| Total size of the files to download, in bytes. | | totalSize | number | Yes| Total size of the files to download, in bytes.|
**Example** **Example**
...@@ -1252,7 +1255,7 @@ Removes this download task. This API uses a promise to return the result. ...@@ -1252,7 +1255,7 @@ Removes this download task. This API uses a promise to return the result.
delete(callback: AsyncCallback&lt;boolean&gt;): void delete(callback: AsyncCallback&lt;boolean&gt;): void
Removes this download task. This API uses an asynchronous callback to return the result. Deletes this download task. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -1262,7 +1265,7 @@ Removes this download task. This API uses an asynchronous callback to return the ...@@ -1262,7 +1265,7 @@ Removes this download task. This API uses an asynchronous callback to return the
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the task removal result.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the task deletion result. |
**Example** **Example**
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
The **system.request** module provides applications with basic upload and download capabilities. The **system.request** module provides applications with basic upload and download capabilities.
> **NOTE** > **NOTE**
> - The APIs of this module are deprecated since API version 9. You are advised to use [@ohos.request](js-apis-request.md) instead.
> >
> - The APIs of this module are deprecated since API version 9. You are advised to use [`@ohos.request`](js-apis-request.md) instead.
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -25,9 +25,9 @@ Uploads a file. This API returns no value. ...@@ -25,9 +25,9 @@ Uploads a file. This API returns no value.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [UploadRequestOptions](#uploadrequestoptions) | Yes| Upload configurations.| | options | [UploadRequestOptions](#uploadrequestoptions) | Yes| Upload configurations.|
**Example** **Example**
...@@ -61,27 +61,27 @@ Uploads a file. This API returns no value. ...@@ -61,27 +61,27 @@ Uploads a file. This API returns no value.
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| url | string | Yes| URL of the upload server.| | url | string | Yes| URL of the upload server.|
| data | Array&lt;[RequestData](#requestdata)&gt; | No| Form data in the request body.| | data | Array&lt;[RequestData](#requestdata)&gt; | No| Form data in the request body.|
| files | Array&lt;[RequestFile](#requestfile)&gt; | Yes| List of files to upload, which is submitted through **multipart/form-data**.| | files | Array&lt;[RequestFile](#requestfile)&gt; | Yes| List of files to upload, which is submitted through **multipart/form-data**.|
| header | Object | No| Request header.| | header | Object | No| Request header.|
| method | string | No| Request method, which can be **'POST'** or **'PUT'**. The default value is **POST**.| | method | string | No| Request method, which can be **'POST'** or **'PUT'**. The default value is **POST**.|
| success | Function | No| Called when API call is successful.| | success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.| | fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.| | complete | Function | No| Called when API call is complete.|
**success parameter** **success parameter**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | [UploadResponse](#uploadresponse) | Yes| Information returned when the upload task is successful.| | data | [UploadResponse](#uploadresponse) | Yes| Information returned when the upload task is successful.|
**fail parameters** **fail parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the upload task fails.| | data | any | Yes| Header information returned when the upload task fails.|
| code | number | Yes| HTTP status code returned when the upload task fails.| | code | number | Yes| HTTP status code returned when the upload task fails.|
...@@ -89,33 +89,33 @@ Uploads a file. This API returns no value. ...@@ -89,33 +89,33 @@ Uploads a file. This API returns no value.
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| code | number | HTTP status code returned by the server.| | code | number | Yes| HTTP status code returned by the server.|
| data | string | Content returned by the server. The value type is determined by the type in the returned headers.| | data | string | Yes| Content returned by the server. The value type is determined by the type in the returned headers.|
| headers | Object | Headers returned by the server.| | headers | Object | Yes| Headers returned by the server.|
## RequestFile ## RequestFile
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| filename | string | No| File name in the header when **multipart** is used.| | filename | string | No| File name in the header when **multipart** is used.|
| name | string | No| Name of a form item when **multipart** is used. The default value is **file**.| | name | string | No| Name of a form item when **multipart** is used. The default value is **file**.|
| uri | string | Yes| Local path for storing files.| | uri | string | Yes| Local path for storing files.|
| type | string | No| Type of the file content. By default, the type is obtained based on the extension of the file name or URI.| | type | string | No| Type of the file content. By default, the type is obtained based on the extension of the file name or URI.|
## RequestData ## RequestData
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the form element.| | name | string | Yes| Name of the form element.|
| value | string | Yes| Value of the form element.| | value | string | Yes| Value of the form element.|
...@@ -129,9 +129,9 @@ Downloads a file. This API returns no value. ...@@ -129,9 +129,9 @@ Downloads a file. This API returns no value.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [DownloadRequestOptions](#downloadrequestoptions) | Yes| Download configurations.| | options | [DownloadRequestOptions](#downloadrequestoptions) | Yes| Download configurations.|
**Example** **Example**
...@@ -164,34 +164,34 @@ Downloads a file. This API returns no value. ...@@ -164,34 +164,34 @@ Downloads a file. This API returns no value.
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| url | string | Yes| Resource URL.| | url | string | Yes| Resource URL.|
| filename | string | No| Name of the file to download. The value is obtained from the current request or resource URL by default.| | filename | string | No| Name of the file to download. The value is obtained from the current request or resource URL by default.|
| header | Object | No| Request header.| | header | Object | No| Request header.|
| description | string | No| Download description. The default value is the file name.| | description | string | No| Download description. The default value is the file name.|
| success | Function | No| Called when API call is successful.| | success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.| | fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.| | complete | Function | No| Called when API call is complete.|
**success parameter** **success parameter**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | [DownloadResponse](#downloadresponse) | Yes| Information returned when the download task is successful.| | data | [DownloadResponse](#downloadresponse) | Yes| Information returned when the download task is successful.|
**fail parameters** **fail parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the download task fails.| | data | any | Yes| Header information returned when the download task fails.|
| code | number | Yes| HTTP status code returned when the download task fails.| | code | number | Yes| HTTP status code returned when the download task fails.|
## DownloadResponse ## DownloadResponse
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
| Name| Type| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| token | string | Download token, which is used to obtain the download status| | token | string | Yes| Download token, which is used to obtain the download status|
## request.onDownloadComplete ## request.onDownloadComplete
...@@ -204,9 +204,9 @@ Listens for download task status. This API returns no value. ...@@ -204,9 +204,9 @@ Listens for download task status. This API returns no value.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [OnDownloadCompleteOptions](#ondownloadcompleteoptions) | Yes| Configurations of the download task.| | options | [OnDownloadCompleteOptions](#ondownloadcompleteoptions) | Yes| Configurations of the download task.|
**Example** **Example**
...@@ -231,29 +231,29 @@ Listens for download task status. This API returns no value. ...@@ -231,29 +231,29 @@ Listens for download task status. This API returns no value.
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| token | string | Yes| Result token returned by the download API.| | token | string | Yes| Result token returned by the download API.|
| success | Function | No| Called when API call is successful.| | success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.| | fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.| | complete | Function | No| Called when API call is complete.|
**success parameter** **success parameter**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | [OnDownloadCompleteResponse](#ondownloadcompleteresponse) | Yes| Information returned when the download task is successful.| | data | [OnDownloadCompleteResponse](#ondownloadcompleteresponse) | Yes| Information returned when the download task is successful.|
**fail parameters** **fail parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| data | any | Yes| Header information returned when the download task fails.| | data | any | Yes| Header information returned when the download task fails.|
| code | number | Yes| HTTP status code returned when the download task fails.| | code | number | Yes| HTTP status code returned when the download task fails.|
## OnDownloadCompleteResponse ## OnDownloadCompleteResponse
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
| Name| Type| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uri | string | URI of the download file.| | uri | string | Yes| URI of the download file.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册