腾讯云wafer2 上传图片错误,代码502
发布于 5 年前 作者 liyao 20041 次浏览 来自 问答

将代码部署在腾讯云上后,上传图片失败,服务器的日志如下:

warning: AppId has been deprecated, Please put it at the end of parameter Bucket(E.g: “test-1250000000”).

/data/release/node-weapp-demo/node_modules/wafer-node-sdk/lib/upload/index.js:113

                const hasBucket = data.Buckets && data.Buckets.reduce((pre, cur) => {

                                      ^

TypeError: Cannot read property ‘Buckets’ of undefined

    at cos.getService (/data/release/node-weapp-demo/node_modules/wafer-node-sdk/lib/upload/index.js:113:39)

    at _callback (/data/release/node-weapp-demo/node_modules/cos-nodejs-sdk-v5/sdk/util.js:333:25)

    at /data/release/node-weapp-demo/node_modules/cos-nodejs-sdk-v5/sdk/base.js:40:20

    at cb (/data/release/node-weapp-demo/node_modules/cos-nodejs-sdk-v5/sdk/base.js:2137:13)

    at Request.<anonymous> (/data/release/node-weapp-demo/node_modules/cos-nodejs-sdk-v5/sdk/base.js:2194:21)

    at emitOne (events.js:120:20)

    at Request.emit (events.js:210:7)

    at IncomingMessage.<anonymous> (/data/release/node-weapp-demo/node_modules/request/request.js:1085:12)

    at Object.onceWrapper (events.js:314:30)

    at emitNone (events.js:110:20)

    at IncomingMessage.emit (events.js:207:7)

    at endReadableNT (_stream_readable.js:1045:12)

    at _combinedTickCallback (internal/process/next_tick.js:138:11)

    at process._tickCallback (internal/process/next_tick.js:180:9)

配置如下:

图片上传的代码用的是demo里的,上传图片后控制台报错:

图片上传成功时的代码:

success: function (res) {

//showSuccess(‘上传图片成功’)

console.log(res);

wx.showToast({

title: “上传图片成功”,

duration: 800

})

res = JSON.parse(res.data)

that.setData({

imgUrl: res.data.imgUrl

})

},

2 回复

我把service/config.js里的appId去掉之后就可以上传图片了

回到顶部