云函数本地调试上传文件uploadFile函数一直报元数据获取失败?
大致源码如下, 路径没有问题:
const cloud = require( 'wx-server-sdk' ) const fs = require( 'fs' ) const path = require( 'path' ) cloud.init({env: 'develop' }) exports.main = async (event, context) => { var readerStream = fs.createReadStream( 'demo.txt' ); var data = '' ; // 处理流事件 --> data, end, and error readerStream.on( 'data' , function (chunk) { data += chunk; }); readerStream.on( 'end' , function (){ console.log( 'demo.jpg!!!!' ) cloud.uploadFile({ cloudPath: 'demo.txt' , fileContent: readerStream, })
|
报错截图: