-
Notifications
You must be signed in to change notification settings - Fork 17
支持多个new Uploader实例吗? #4
Description
在循环上传文件的时config中的mergeUrl、query始终为一个值,未根据列表设置
weiXinNewUpload(taskInfo,fileIdx,taskIdx){
let mergeUrl = this.$setting.baseURL + '/' + this.$setting.ms_sobey_api +"material/v2/upload/multipart/weixin/merge";
mergeUrl += ((mergeUrl.indexOf('?') == -1) ? '?' : '&') + 'access_token=' + this.vuex_token.access_token;
mergeUrl += ((mergeUrl.indexOf('?') == -1) ? '?' : '&') + 'taskId=' + taskInfo.taskId;
mergeUrl += ((mergeUrl.indexOf('?') == -1) ? '?' : '&') + 'province=' + this.vuex_user.province;
let current = this.uploadTaskList[taskIdx];
let uploadConfig = {};
uploadConfig = {
tempFilePath:!current.file.tempFilePath?current.file.path:current.file.tempFilePath,
totalSize: current.file.size,
fileName: current.file.name,
uploadUrl: this.uploadBaseUrl,
mergeUrl: mergeUrl,
testChunks: false,
verbose: true,
chunkSize:210241024,
maxConcurrency:3,
timeout:600000,
chunkRetryInterval:5000,
maxChunkRetries:5,
header: {
Method: "POST",
Authorization:'Bearer ' + this.vuex_token.access_token
},
query: {
fileId:taskInfo.fileId,
taskId:taskInfo.taskId
}
}
let uploader = new Uploader(uploadConfig);
this.uploadTaskList[taskIdx].uploader = uploader;
uploader.upload();
uploader.on("success",(res)=>{
console.log(res)
if(!res.code){
let groupType = this.fileTypeCheck(current.file.name);
let params = {
title: current.file.name,
catalogId: this.catalogChildrenId,
groupType: groupType,
sort: 1,
deptId: this.vuex_user.orgCode,
deptName: this.vuex_user.orgName,
isPublic: 0,
fileId: taskInfo.fileId,
filePath: res.data, //url
fileIdx
}
this.savaFile(params);
}else{
uploader.pause();
this.fileList[fileIdx].isError = true;
}
})
// 文件进度变化
uploader.on('progress', (res) => {
console.log("progress",res);
this.fileList[fileIdx].percent = res.progress;
this.$forceUpdate();
})
// 文件上传失败
uploader.on('fail', (res) => {
console.log('fail', res)
uploader.pause();
this.fileList[fileIdx].isError = true;
})
},