HomeDocs
Skip to main content

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

AttributeTypeDescription
successstringtrue - successful
false - failed
errCodestringError code returned when the operation fails.
errMsgstringError message returned when the operation fails.

Explanation of errMsg

Error MessageExplanation
UploadFile Abort Fail, callbackId is empty: U007Operation failed, upload task not found
UploadFile Abort Fail, Exception_" + t.toString() +: U008Operation failed, exception information
UploadFile Abort Fail, "+error+": U009Operation 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
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.