Skip to content

引入

ts
import { uploadCOSFile } from 't-comm';

// 不支持 tree-shaking 的项目
import { uploadCOSFile} from 't-comm/lib/tencent-cloud/cos/index';

// 只支持 ESM 的项目
import { uploadCOSFile} from 't-comm/es/tencent-cloud/cos/index';

uploadCOSFile(config)

描述

COS上传

参数

参数名类型描述
configobject

配置信息

config.filesArray<object>

文件列表

config.files.keystring

文件key

config.files.pathstring

文件路径

config.secretIdstring

COS secretId

config.secretKeystring

COS secretKey

config.bucketstring

COS bucket

config.regionstring

COS region

返回: Promise.<object>

请求Promise

示例

typescript
uploadCOSFile({
  files: [{
    key: 'key1',
    path: 'path1',
  }, {
    key: 'key2',
    path: 'path2',
  }],
  secretId: 'xxx',
  secretKey: 'xxx',
  bucket: 'xxx',
  region: 'xxx',
})