UploadTask.abort(params: Object)

版本要求:
BaseKit≥2.0.1
支持平台:
iOSAndroid

描述

中断上传任务

参数

属性类型必填说明
complete() => void否接口调用结束的回调函数(调用成功、失败都会执行)
success() => void否接口调用成功的回调函数
fail(params: Object) => void否接口调用失败的回调函数
fail 回调参数
属性类型说明
errorMsgstring错误信息
errorCodestring | number错误码
错误扩展

返回值

无

示例代码

import { downloadFile, uploadFile } from '@ray-js/ray'

// 中断上传任务:拿到 UploadTask 后调用 task.abort()
downloadFile({
  url: "https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/ttttestfile/test_image.jpg",
  success: ({ tempFilePath }) => {
    const task = uploadFile({
      url: "https://httpbin.org/post",
      filePath: tempFilePath,
      name: "file",
      success: () => {
        task.abort({
          success: () => console.log("已中断上传任务"),
          fail: error => console.error(error),
        });
      },
      fail: error => console.error(error),
    });
  },
  fail: error => console.error(error),
});