引入
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上传
参数:
参数名 | 类型 | 描述 |
---|---|---|
config | object | 配置信息 |
config.files | Array<object> | 文件列表 |
config.files.key | string | 文件key |
config.files.path | string | 文件路径 |
config.secretId | string | COS secretId |
config.secretKey | string | COS secretKey |
config.bucket | string | COS bucket |
config.region | string | COS region |
返回: Promise.<object>
请求Promise
示例
typescript
uploadCOSFile({
files: [{
key: 'key1',
path: 'path1',
}, {
key: 'key2',
path: 'path2',
}],
secretId: 'xxx',
secretKey: 'xxx',
bucket: 'xxx',
region: 'xxx',
})