uploadFile http 文件上传

uploadFile ^6.8

http 文件上传

#请求参数

Prop Type Value Comment
url String - 服务器地址
filePath Object - 要上传文件资源的路径 (本地相对路径)
name Number - 文件对应的 key
header Number - HTTP 请求的 Header,Header 中不能设置 Referer
formData Number - HTTP 请求中其他额外的 form data
timeout Number - 超时时间,单位为毫秒

#引入接口模块

import bridge from '@minix-iot/etsbridge-sdk'

#参数代码示例

let params = {
  url: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3105753044,45676271&fm=26&gp=0.jpg',
  filePath: 'downFiles/timg.jpeg',
  name: 'keyname',
  header: {},
  formData: {}, //HTTP 请求中其他额外的 form data
  timeout: 10000,
}

#接口调用示例

let params = {
  url: this.url,
  filePath: this.filePath,
  name: this.name,
  header: this.header,
  formData: this.formData,
  timeout: this.timeout,
}
bridge
  .uploadFile(params)
  .then((res) => {
    console.log(res)
  })
  .catch((err) => {
    console.log(err)
  })

#返回参数

  • 成功时返回
Prop Type Comment
code Number -
msg String -

#返回示例

{
    "code": 0,
    "msg": "success"
}
posted on 2024-12-28 16:36  AtlasLapetos  阅读(12)  评论(0)    收藏  举报