title: UploadTask

sidebar_label: UploadTask

Listens on the upload progress change event and cancels upload tasks.

Reference

Methods

abort

Aborts upload tasks.

Reference

  1. () => void

API Support

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

offHeadersReceived

Listens on HTTP Response Header event, which will be earlier than the request completion 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
UploadTask.offHeadersReceived ✔️

offProgressUpdate

Un-listens on the upload progress change event.

Reference

  1. (callback: OffProgressUpdateCallback) => void
Property Type Description
callback OffProgressUpdateCallback The callback function for the upload progress change event.

API Support

API WeChat Mini-Program H5 React Native
UploadTask.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
UploadTask.onHeadersReceived ✔️

headersReceived

  1. (callback: OnHeadersReceivedCallback) => void
Property Type Description
callback OnHeadersReceivedCallback The callback function for the HTTP Response Header event

onProgressUpdate

Listens on the upload progress change event.

Reference

  1. (callback: OnProgressUpdateCallback) => void
Property Type Description
callback OnProgressUpdateCallback The callback function for the upload progress change event.

API Support

API WeChat Mini-Program H5 React Native
UploadTask.onProgressUpdate ✔️

progress

  1. (callback: OnProgressUpdateCallback) => void
Property Type Description
callback OnProgressUpdateCallback The callback function for the upload progress change event.

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 upload 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 upload 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 Upload progress percentage
totalBytesExpectedToSend number The length of data expected to be uploaded, in bytes
totalBytesSent number The length of uploaded data, in bytes

API Support

API WeChat Mini-Program H5 React Native
UploadTask.abort ✔️
UploadTask.offHeadersReceived ✔️
UploadTask.offProgressUpdate ✔️
UploadTask.onHeadersReceived ✔️
UploadTask.onProgressUpdate ✔️