以Promise风格调用: 支持
一个可以监听上传进度变化事件,以及取消上传任务的对象
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) => { console.log('上传进度', res.progress) console.log('已经上传的数据长度', res.totalBytesSent) console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend) }) uploadTask.abort() // 取消上传任务