微信小程序服务端API 上传图片出现错误。
服务端代码:
const cloud = require(‘wx-server-sdk’)
cloud.init()
const fs = require(‘fs’)
exports.main = async (event, context) => {
const fileStream = fs.createReadStream(event.fileStream)
return await cloud.uploadFile({
cloudPath: event.cloudPath,
fileContent: fileStream,})}
用户端代码:
var cloudPath = “sss/yyy/m000.jpg”
var fileStream = ‘cloud://暂时隐藏/my.jpg’
wx.cloud.callFunction({
name: ‘imgdoupload’,
data: {
cloudPath: cloudPath,
fileStream: fileStream
},
success: res => {
console.log(‘success–res’)
console.log(res)
}, fail: res => {
console.log(’ fail–res’)
console.log(res)
}
},2000)
运行时出现上传失败:
fail–res
Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 708c4dfe-243a-11e9-ab66-525400235f2a, cloud function service error code -504002, error message ENOENT: no such file or directory, open ‘cloud://暂时隐藏/my.jpg’; at cloud.callFunction api;
at new e (WAService.js:1)
at u (WAService.js:1)
at Object.t.returnAsFinalCloudSDKError (WAService.js:1)
at Function.success (WAService.js:1)
at WAService.js:1
at Qe (WAService.js:1)
at Bt.<anonymous> (WAService.js:1)
at Bt.emit (WAService.js:1)
at ji (WAService.js:1)
at WAService.js:1
实在不知问题出现在哪里,还请大神不吝赐教!!!!!!