How to pipe/stream file into API Response object?
I'm trying to write an API endpoint with SolidStart which would read a file with
fs.createReadStream
and pipe it into a Response
object which is returned by the API function. I was unable to find a proper solution for this, is it possible at all and how?4 Replies
You would need to convert NodeJS stream into a Web stream
https://nodejs.org/api/stream.html#streamreadabletowebstreamreadable-options
or you can do this manually
The problem is I can't find any property that would allow me to stream and kind of stream back.
Response.body
is readonly and constructor of Response doesn't allow to set up a stream for a body (as far as I was digging into it)you can. You just need to pass a ReadableStream to Response
That's what I'm having problems with, I couldn't find a way how. Typescript is giving me errors.............
Do you have an example?