上传功能
1. 上传COS(upload)
使用方法
typescript
import { Upload } from 'antd';
const HandleCustomRequest= (e: any) => {
const mediaFile = e.file;
const { uploadFile } = homingClient.Upload({
cosConfig: {
Bucket: 'meiye-1323116912', //存储桶
Region: 'ap-guangzhou', //地域
Domain: 'meiye.cos.clife.cn',
},
agentCode: "", // 产品线code
bizSenceCode: "", // 业务code
childrenBizSenceCode: "", //子业务code
tenantCode: "", //租户code
fristVideoFrame: "", //是否需要视频首帧
needTranscode:"" //是否需要转码
})
uploadFile({
file: mediaFile,
})
.then((data: any) => {
const { imageUrl = '', duration, fristVideoFrameUrl = '' } = data;
console.log(data)
})
.catch((err) => {
console.log(err)
});
}
<Upload customRequest={(e) => {
HandleCustomRequest(e);
}}>
<Button>图片上传</Button>
</Upload>
参数说明
参数名 | 类型 | 必填 | 说明 | 备注/枚举值 |
---|---|---|---|---|
cosConfig | object | 是 | cos配置 | 默认值:{ Bucket: 'meiye-1323116912', Region: 'ap-guangzhou', Domain: 'meiye.cos.clife.cn' } |
agentCode | string | 是 | 业务线code值 | 默认homing(美业),用来区分是哪个产品线 |
bizSenceCode | string | 是 | 业务模块code值 | 默认值other,用来区分业务模块 |
childrenBizSenceCode | string | 否 | 子业务模块code值 | 无 |
tenantCode | string | 是 | 租户code值 | 默认值0,用来区分当前是属于哪个租户 |
fristVideoFrame | string | 否 | 是否需要视频首帧 | |
needTranscode | string | 否 | 是否需要转码 |
响应说明
返回函数
字段名 | 类型 | 说明 |
---|---|---|
uploadFile | function | 上传文件函数 |
uploadFile 函数参数
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
file | File | 是 | 文件内容 |
uploadFile 函数返回值(data 对象)
字段名 | 类型 | 说明 |
---|---|---|
imageUrl | string | 图片地址 |
duration | number | 视频时长(视频文件时返回) |
transcodeUrl | string | 转码后图片地址(needsTranscodeFlag=true时返回) |
fristVideoFrameUrl | string | 视频首帧url(fristVideoFrame=true返回) |