miniprogram-file-uploader icon indicating copy to clipboard operation
miniprogram-file-uploader copied to clipboard

支持多个new Uploader实例吗?

Open wYuJian opened this issue 3 years ago • 2 comments

在循环上传文件的时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; }) },

wYuJian avatar Oct 13 '21 08:10 wYuJian

请问解决了吗,我也遇到这个问题了

1647229629 avatar Sep 28 '22 07:09 1647229629

image

看着库有bug! @1647229629 @wYuJian

改成:this.config = Object.assign({}, config, option); 即可

0zcl avatar Feb 23 '23 08:02 0zcl