Skip to content

上传功能

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>

参数说明

参数名类型必填说明备注/枚举值
cosConfigobjectcos配置默认值:{ Bucket: 'meiye-1323116912', Region: 'ap-guangzhou', Domain: 'meiye.cos.clife.cn' }
agentCodestring业务线code值默认homing(美业),用来区分是哪个产品线
bizSenceCodestring业务模块code值默认值other,用来区分业务模块
childrenBizSenceCodestring子业务模块code值
tenantCodestring租户code值默认值0,用来区分当前是属于哪个租户
fristVideoFramestring是否需要视频首帧
needTranscodestring是否需要转码

响应说明

返回函数

字段名类型说明
uploadFilefunction上传文件函数

uploadFile 函数参数

参数名类型必填说明
fileFile文件内容

uploadFile 函数返回值(data 对象)

字段名类型说明
imageUrlstring图片地址
durationnumber视频时长(视频文件时返回)
transcodeUrlstring转码后图片地址(needsTranscodeFlag=true时返回)
fristVideoFrameUrlstring视频首帧url(fristVideoFrame=true返回)

基于 MIT 许可证发布