Skip to content
On this page

UploadTask.onProgressUpdate

监听上传进度变化事件。

Result

属性类型说明
progressnumber上传进度百分比, 0 - 100
totalBytesWrittennumber已经上传的数据长度,单位 Bytes
totalBytesExpectedToWritenumber预期需要上传的数据总长度,单位 Bytes

Example

ts
const task = ek.uploadFile({
  url: 'https://example.com/upload',
  // ...
  success: res => {
    console.log('success')
  },
  fail: res => {
    console.log(res.errMsg)
  }
})

task.onProgressUpdate(res => {
  console.log(`progress: ${res.progress}%`)
})