扫描小程序码分享
一次上传超过两张图片,会出现“uploadFile:fail createUploadTask:fail exceed max upload connection count”报错,如何解决?
错误码:-503001
4 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
加async await后已经解决这个问题了,谢谢大佬们提醒
// 选择图片 choose_pic: function () { wx.chooseImage({ count: 9, sizeType: ['original'], success: (res) => { this.data.tempFilePaths = res.tempFilePaths this.upload_pic() }, }) }, // 上传至云端存储 upload_pic: async function () { wx.showLoading({ title: '上传中...', }) let length = this.data.tempFilePaths.length; for (let i = 0; i < length; i++) { console.log('i', i) let item = this.data.tempFilePaths[i] await wx.cloud.uploadFile({ cloudPath: 'uploadImages/' + Date.now() + item.match(/\.[^.]+?$/)[0], // 文件名称 filePath: item, }).then(res => { console.log('i', i) console.log('上传云成功', res) }).catch(err => { console.log('上传云失败', err) }) } wx.hideLoading() },
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
在我这边运行,毫无问题。
这个不支持并行上传
多次上传循环调用
// 选择图片
choose_pic: function () {
wx.chooseImage({
count: 9,
sizeType: ['original'],
success: (res) => {
this.data.tempFilePaths = res.tempFilePaths
this.upload_pic()
},
})
// 上传至云端存储
upload_pic: function () {
wx.showLoading({
title: '上传中...',
let length = this.data.tempFilePaths.length;
for (let i = 0; i < length; i++) {
let item = this.data.tempFilePaths[i]
wx.cloud.uploadFile({
cloudPath: 'uploadImages/' + Date.now() + item.match(/\.[^.]+?$/)[0], // 文件名称
filePath: item,
}).then(res => {
console.log('上传云成功', res)
}).catch(err => {
console.log('上传云失败', err)
}
wx.hideLoading()
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
加async await后已经解决这个问题了,谢谢大佬们提醒
// 选择图片 choose_pic: function () { wx.chooseImage({ count: 9, sizeType: ['original'], success: (res) => { this.data.tempFilePaths = res.tempFilePaths this.upload_pic() }, }) }, // 上传至云端存储 upload_pic: async function () { wx.showLoading({ title: '上传中...', }) let length = this.data.tempFilePaths.length; for (let i = 0; i < length; i++) { console.log('i', i) let item = this.data.tempFilePaths[i] await wx.cloud.uploadFile({ cloudPath: 'uploadImages/' + Date.now() + item.match(/\.[^.]+?$/)[0], // 文件名称 filePath: item, }).then(res => { console.log('i', i) console.log('上传云成功', res) }).catch(err => { console.log('上传云失败', err) }) } wx.hideLoading() },
在我这边运行,毫无问题。
这个不支持并行上传
多次上传循环调用
// 选择图片
choose_pic: function () {
wx.chooseImage({
count: 9,
sizeType: ['original'],
success: (res) => {
this.data.tempFilePaths = res.tempFilePaths
this.upload_pic()
},
})
},
// 上传至云端存储
upload_pic: function () {
wx.showLoading({
title: '上传中...',
})
let length = this.data.tempFilePaths.length;
for (let i = 0; i < length; i++) {
let item = this.data.tempFilePaths[i]
wx.cloud.uploadFile({
cloudPath: 'uploadImages/' + Date.now() + item.match(/\.[^.]+?$/)[0], // 文件名称
filePath: item,
}).then(res => {
console.log('上传云成功', res)
}).catch(err => {
console.log('上传云失败', err)
})
}
wx.hideLoading()
},