const $S = require('scriptjs');
async componentDidMount() {
let uploadToken = await this.getUploadToken();
$S([
'https://dn-kdjz.qbox.me/js/plupload/2.1.1/plupload.full.min.js',
'https://dn-kdjz.qbox.me/js/qiniu-js-sdk/1.0.17.2/qiniu.min.js'
], 'uploadBundle');
$S.ready('uploadBundle', () => {
// 证件合影
let options1 = {
runtimes: 'html5,flash,html4',
browse_button: 'photoId',
uptoken: uploadToken,
get_new_uptoken: false,
domain: 'https://xxxx.xxxxxx', // bucket域名,下载资源时用到,必需
container: 'photoIdContainer', // 上传区域DOM ID,默认是browser_button的父元素
max_file_size: '100mb', // 最大文件体积限制
flash_swf_url: '/js/plupload/2.2.1/Moxie.swf', //引入flash,相对路径
max_retries: 3, // 上传失败最大重试次数
dragdrop: true, // 开启可拖曳上传
drop_element: 'photoIdContainer', // 拖曳上传区域元素的ID,拖曳文件或文件夹后可触发上传
chunk_size: '4mb', // 分块上传时,每块的体积
auto_start: true, // 选择文件后自动上传,若关闭需要自己绑定事件触发上传
init: {
'FilesAdded': (up, files) => {
plupload.each(files, function(file) {
// 文件添加进队列后,处理相关的事情
});
},
'BeforeUpload': (up, file) => {
// 每个文件上传前,处理相关的事情
},
'UploadProgress': (up, file) => {
// 每个文件上传时,处理相关的事情
},
'FileUploaded': async(up, file, info) => {
// 查看简单反馈
let domain = up.getOption('domain');
let res = JSON.parse(info);
let sourceLink = await this.getDownloadUrl(res.key);
this.setState({
photoIdKey: res.key,
photoId: sourceLink
})
},
'Error': (up, err, errTip) => {
//上传出错时,处理相关的事情
console.log(err);
},
'UploadComplete': () => {
//队列文件处理完毕后,处理相关的事情
console.log('上传完成');
},
'Key': (up, file) => {
let timestamp = parseInt((new Date().valueOf() / 1000));
// 若想在前端对每个文件的key进行个性化处理,可以配置该函数
// 该配置必须要在unique_names: false,save_key: false时才生效
let key = `idcard/${timestamp}_${file.name}`;
return key
}
}
};
// 第一个按钮
const uploader1 = Qiniu.uploader(options1);
})
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有