Skip to main content
Version: 3.x

UploadTask

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

Reference

Methods

abort

Aborts upload tasks.

Reference

() => void

API Support

APIWeChat Mini-ProgramH5React Native
UploadTask.abort✔️

offHeadersReceived

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

Reference

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

API Support

APIWeChat Mini-ProgramH5React Native
UploadTask.offHeadersReceived✔️

offProgressUpdate

Un-listens on the upload progress change event.

Reference

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

API Support

APIWeChat Mini-ProgramH5React Native
UploadTask.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
UploadTask.onHeadersReceived✔️

headersReceived

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

onProgressUpdate

Listens on the upload progress change event.

Reference

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

API Support

APIWeChat Mini-ProgramH5React Native
UploadTask.onProgressUpdate✔️

progress

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

Parameters

OffHeadersReceivedCallback

The callback function for the HTTP Response Header event

(res: CallbackResult) => void
PropertyType
resCallbackResult

OffProgressUpdateCallback

The callback function for the upload 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 upload progress change event.

(result: OnProgressUpdateCallbackResult) => void
PropertyType
resultOnProgressUpdateCallbackResult

OnHeadersReceivedCallbackResult

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

OnProgressUpdateCallbackResult

PropertyTypeDescription
progressnumberUpload progress percentage
totalBytesExpectedToSendnumberThe length of data expected to be uploaded, in bytes
totalBytesSentnumberThe length of uploaded data, in bytes

API Support

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