UploadTask.abort(function listener)
Introduction
Abort an upload task.
Parameters
function listener
A callback function for the result of the abort
operation.
Parameters
Object res
Attribute | Type | Description |
---|---|---|
success | string | true - successful false - failed |
errCode | string | Error code returned when the operation fails. |
errMsg | string | Error message returned when the operation fails. |
Explanation of errMsg
Error Message | Explanation |
---|---|
UploadFile Abort Fail, callbackId is empty: U007 | Operation failed, upload task not found |
UploadFile Abort Fail, Exception_" + t.toString() +: U008 | Operation failed, exception information |
UploadFile Abort Fail, "+error+": U009 | Operation failed, error information |
Sample Code
// pages/index/index.js
Page({
uploadFile() {
const uploadTask = dlt.uploadFile({
url: "xxx",
filePath: tempFilePaths[0],
formData: {
user: "test",
},
success(res) {
console.log(res);
},
fail(res) {
console.error(res);
},
});
uploadTask.abort((res) => {
console.log(res);
}); // Cancel the upload task
},
});