Unable to stream to concat-stream
Closed this issue · 3 comments
andrewspy commented
I intend to output the stream to string using concat-stream
instead of writing to file system, but it doesn't seems to work. below is the sample code:-
let concat = require('concat-stream');
...
.then(streamResult => {
// using the length property you can do things like
// directly upload the image to s3 by using the
// stream and length properties
streamResult.stream // => Stream object
streamResult.length // => Integer length of stream
let imgStr = '';
let cs = concat(buffer => {
imgStr = buffer.toString('base64');
console.log(imgStr);
});
streamResult.stream.pipe(cs);
// write to a file
// return chartNode.writeImageToFile('image/png', './testimage.png');
})
.then(() => {
// chart is now written to the file path
// ./testimage.png
});
I am new to javascript and stream, and hope someone can give me a pointer. Thanks!
sedouard commented
Thanks for reporting this @andrewspy looks like we aren't closing the ReadableStream
we're providing you. PR #15 will fix this. I'll have a new package out shortly.