1.引入 ‘qiniu-js’;
import * as qiniu from 'qiniu-js';
2.配置qiuui对象
// 七牛云文件上传
qiniuUploadFile = (uploadItem: any) => {
let { uploadToken, dispatch, uploadRegion } = this.props;
console.log(uploadRegion, 666);
// 七牛云上传配置信息
var config = {
useCdnDomain: true,
retryCount: 6,
region: {
'z0': qiniu.region.z0, //华东
'z1': qiniu.region.z1, //华北
'z2': qiniu.region.z2, //华南
'na0': qiniu.region.na0, //北美
'as0': qiniu.region.as0 //新加坡
}[`${uploadRegion}`],
};
var putExtra = {
fname: uploadItem.title,
params: {},
mimeType: null,
};
我这里的uploadRegion是后台返回的,所以能动态控制上传地区。