云函数 getSaveImage:
// 云函数入口文件 const cloud = require( 'wx-server-sdk' ) const fs = require( 'fs' ) const path = require( 'path' ) const request = require( 'request' ); cloud.init() // 云函数入口函数 exports.main = async (event, context) => { request({ host: "img.php.cn" , path: "/upload/avatar/000/001/506/5922afcbb3cf4752.jpg" }, (res) => { var stream = fs.createWriteStream( "demo.jpg" ); res.pipe(stream); console.log(res) cloud.uploadFile({ cloudPath: 'demo.jpg' , fileContent: res, }) } ); } |
小程序端调用该云函数,开发工具报错:
VM370: 1 Error: errCode: - 404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 17818a24-269f-11e9-99f3- 525400770114 , cloud function service error code - 504002 , error message res.pipe is not a function ; at cloud.callFunction api; |
请问这是为什么?res.pipe is not a function
最后问题咋解决了啊?我也遇到这个问题了
参考
https://developers.weixin.qq.com/community/develop/doc/000ce8c0a28ad0019197b373156004