以Promise风格调用: 不支持。
监听上传进度变化事件
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
callback | function | 否 | 监听上传进度变化事件 |
属性 | 类型 | 说明 |
---|---|---|
progress | number | 上传进度百分比 |
totalBytesSent | number | 已经上传的数据长度,单位 Bytes |
totalBytesExpectedToSend | number | 预期需要上传的数据总长度,单位 Bytes |
const uploadTask = xhs.uploadFile({ url: 'http://example.xiaohongshu.com/upload', //仅为示例,非真实的接口地址 filePath: tempFilePaths[0], name: 'file', success (res){ const data = res.data //do something } }) uploadTask.onProgressUpdate(res => { // })