title: DownloadTask
sidebar_label: DownloadTask
Methods
abort
Aborts download tasks.
Reference
() => void
API Support
| API |
WeChat Mini-Program |
H5 |
React Native |
| DownloadTask.abort |
✔️ |
|
✔️ |
offHeadersReceived
Un-listens on the HTTP Response Header event.
Reference
(callback: OffHeadersReceivedCallback) => void
| Property |
Type |
Description |
| callback |
OffHeadersReceivedCallback |
The callback function for the HTTP Response Header event. |
API Support
| API |
WeChat Mini-Program |
H5 |
React Native |
| DownloadTask.offHeadersReceived |
✔️ |
|
offProgressUpdate
Un-listens on download progress change events.
Reference
(callback: OffProgressUpdateCallback) => void
| Property |
Type |
Description |
| callback |
OffProgressUpdateCallback |
The callback function for the download progress change event. |
API Support
| API |
WeChat Mini-Program |
H5 |
React Native |
| DownloadTask.offProgressUpdate |
✔️ |
|
✔️ |
onHeadersReceived
Listens on HTTP Response Header event, which will be earlier than the request completion event.
Reference
(callback: OnHeadersReceivedCallback) => void
| Property |
Type |
Description |
| callback |
OnHeadersReceivedCallback |
The callback function for the HTTP Response Header event. |
API Support
| API |
WeChat Mini-Program |
H5 |
React Native |
| DownloadTask.onHeadersReceived |
✔️ |
|
onProgressUpdate
Listens on the download progress change event.
Reference
(callback: OnProgressUpdateCallback) => void
| Property |
Type |
Description |
| callback |
OnProgressUpdateCallback |
The callback function for the download progress change event. |
API Support
| API |
WeChat Mini-Program |
H5 |
React Native |
| DownloadTask.onProgressUpdate |
✔️ |
|
✔️ |
Parameters
OffHeadersReceivedCallback
The callback function for the HTTP Response Header event.
(res: CallbackResult) => void
| Property |
Type |
| res |
CallbackResult |
OffProgressUpdateCallback
The callback function for the download progress change event.
(res: CallbackResult) => void
| Property |
Type |
| res |
CallbackResult |
OnHeadersReceivedCallback
The callback function for the HTTP Response Header event.
(result: OnHeadersReceivedCallbackResult) => void
| Property |
Type |
| result |
OnHeadersReceivedCallbackResult |
OnProgressUpdateCallback
The callback function for the download progress change event.
(result: OnProgressUpdateCallbackResult) => void
| Property |
Type |
| result |
OnProgressUpdateCallbackResult |
OnHeadersReceivedCallbackResult
| Property |
Type |
Description |
| header |
Record<string, any> |
HTTP Response Header returned by the developer server |
OnProgressUpdateCallbackResult
| Property |
Type |
Description |
| progress |
number |
Download progress percentage |
| totalBytesWritten |
number |
The length of downloaded data, in bytes |
| totalBytesExpectedToWrite |
number |
The length of data expected to be downloaded, in bytes |
API Support
| API |
WeChat Mini-Program |
H5 |
React Native |
| DownloadTask.abort |
✔️ |
|
✔️ |
| DownloadTask.offHeadersReceived |
✔️ |
|
|
| DownloadTask.offProgressUpdate |
✔️ |
|
✔️ |
| DownloadTask.onHeadersReceived |
✔️ |
|
|
| DownloadTask.onProgressUpdate |
✔️ |
|
✔️ |