Skip to main content
Version: 3.x

DownloadTask

Methods​

abort​

Aborts download tasks.

Reference

() => void

API Support​

APIWeChat Mini-ProgramH5React Native
DownloadTask.abort✔️✔️

offHeadersReceived​

Un-listens on the HTTP Response Header event.

Reference

(callback: OffHeadersReceivedCallback) => void
PropertyTypeDescription
callbackOffHeadersReceivedCallbackThe callback function for the HTTP Response Header event.

API Support​

APIWeChat Mini-ProgramH5React Native
DownloadTask.offHeadersReceived✔️

offProgressUpdate​

Un-listens on download progress change events.

Reference

(callback: OffProgressUpdateCallback) => void
PropertyTypeDescription
callbackOffProgressUpdateCallbackThe callback function for the download progress change event.

API Support​

APIWeChat Mini-ProgramH5React Native
DownloadTask.offProgressUpdate✔️✔️

onHeadersReceived​

Listens on HTTP Response Header event, which will be earlier than the request completion event.

Reference

(callback: OnHeadersReceivedCallback) => void
PropertyTypeDescription
callbackOnHeadersReceivedCallbackThe callback function for the HTTP Response Header event.

API Support​

APIWeChat Mini-ProgramH5React Native
DownloadTask.onHeadersReceived✔️

onProgressUpdate​

Listens on the download progress change event.

Reference

(callback: OnProgressUpdateCallback) => void
PropertyTypeDescription
callbackOnProgressUpdateCallbackThe callback function for the download progress change event.

API Support​

APIWeChat Mini-ProgramH5React Native
DownloadTask.onProgressUpdate✔️✔️

Parameters​

OffHeadersReceivedCallback​

The callback function for the HTTP Response Header event.

(res: CallbackResult) => void
PropertyType
resCallbackResult

OffProgressUpdateCallback​

The callback function for the download progress change event.

(res: CallbackResult) => void
PropertyType
resCallbackResult

OnHeadersReceivedCallback​

The callback function for the HTTP Response Header event.

(result: OnHeadersReceivedCallbackResult) => void
PropertyType
resultOnHeadersReceivedCallbackResult

OnProgressUpdateCallback​

The callback function for the download progress change event.

(result: OnProgressUpdateCallbackResult) => void
PropertyType
resultOnProgressUpdateCallbackResult

OnHeadersReceivedCallbackResult​

PropertyTypeDescription
headerRecord<string, any>HTTP Response Header returned by the developer server

OnProgressUpdateCallbackResult​

PropertyTypeDescription
progressnumberDownload progress percentage
totalBytesWrittennumberThe length of downloaded data, in bytes
totalBytesExpectedToWritenumberThe length of data expected to be downloaded, in bytes

API Support​

APIWeChat Mini-ProgramH5React Native
DownloadTask.abort✔️✔️
DownloadTask.offHeadersReceived✔️
DownloadTask.offProgressUpdate✔️✔️
DownloadTask.onHeadersReceived✔️
DownloadTask.onProgressUpdate✔️✔️