生成二维码并保存云存储中,uploadFile总报错,但报错信息看不懂
发布于 5 年前 作者 leiping 1955 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

2019-06-05T14:54:51.897Z  { Error: errCode: -1 unknown error | errMsg: uploadFile:fail TypeError: source.on is not a function; at uploadFile api;

at new CloudSDKError (/var/user/node_modules/wx-server-sdk/index.js:6173:28)

at returnAsCloudSDKError (/var/user/node_modules/wx-server-sdk/index.js:6225:16)

at Object.returnAsFinalCloudSDKError (/var/user/node_modules/wx-server-sdk/index.js:6239:13)

at Cloud.<anonymous> (/var/user/node_modules/wx-server-sdk/index.js:2703:62)

at step (/var/user/node_modules/tslib/tslib.js:133:27)


  • 预期表现

生成商家二维码并保存云存储中

  • 复现路径
  • 提供一个最简复现 Demo

exports.main = async (event, context) => {

try {

let imgBuf = await cloud.openapi.wxacode.getUnlimited({

page: “pages/seller/seller”,

scene: “?sellerId=71f2cd945cb0b2e304fc61”,

width: 160,

autoColor: false,

lineColor: { “r”: 87, “g”: 134, “b”: 100 },

isHyaline: true

})

const result = await cloud.uploadFile({

cloudPath: ‘71f2cd945cb0b2e304fc6126353113**/code.png’,

fileContent: imgBuf

})

return result

} catch (err) {

console.log(err)

return err

}

}

1 回复

已解决,疏忽了,应该是imgBuf.buffer

回到顶部