我试图通过管道将大型数组作为csv响应发送给rest api。
我使用以下代码
var Stream = require('stream')
var readable = new Stream.Readable();
for (var i=0; i<arr.length; i++){
readable.push(arr[i]);
}
readable.push(null);
readable.pipe(response);
我收到以下错误
RangeError: Invalid string length
fs.js:158
at Array.toString (native)
at nullCheck (fs.js:158:11)
at Object.fs.open (fs.js:631:8)
at ReadStream.open (fs.js:1982:6)
at new ReadStream (fs.js:1969:10)
at Object.fs.createReadStream (fs.js:1923:10)
任何帮助将不胜感激。谢谢