title: DownloadTask

sidebar_label: DownloadTask

Methods

abort

Aborts download tasks.

Reference

  1. () => void

API Support

API WeChat Mini-Program H5 React Native
DownloadTask.abort ✔️ ✔️

offHeadersReceived

Un-listens on the HTTP Response Header event.

Reference

  1. (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

  1. (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

  1. (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

  1. (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.

  1. (res: CallbackResult) => void
Property Type
res CallbackResult

OffProgressUpdateCallback

The callback function for the download progress change event.

  1. (res: CallbackResult) => void
Property Type
res CallbackResult

OnHeadersReceivedCallback

The callback function for the HTTP Response Header event.

  1. (result: OnHeadersReceivedCallbackResult) => void
Property Type
result OnHeadersReceivedCallbackResult

OnProgressUpdateCallback

The callback function for the download progress change event.

  1. (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 ✔️ ✔️