网络

ac.uploadFile

通过宿主能力上传文件。

权限:network 宿主 API

功能描述

通过宿主能力上传文件。

调用方式

const result = await ac.uploadFile({
  "url": "string",
  "name": "string"
});

参数说明

属性类型必填说明
urlstring-
filePathstring-
fileobject-
namestring-
formDataobject-
headerobject-
timeoutnumber-
{
  "type": "object",
  "required": [
    "url",
    "name"
  ],
  "properties": {
    "url": {
      "type": "string"
    },
    "filePath": {
      "type": "string"
    },
    "file": {},
    "name": {
      "type": "string"
    },
    "formData": {
      "type": "object"
    },
    "header": {
      "type": "object"
    },
    "timeout": {
      "type": "number"
    }
  }
}

返回值

{
  "type": "object"
}

错误码

该 API 当前没有声明专属错误码。

Manifest 声明

Agent 生成小程序时,如果页面会调用该 API,应在 manifest.apisUsed 中声明完整 API 名称。

{
  "permissions": [
    "network"
  ],
  "apisUsed": [
    "ac.uploadFile"
  ]
}

平台支持

平台支持情况
Web支持
Android SDK支持
iOS SDK支持
Flutter SDK支持