S
SolidJS12mo ago
m5

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
lxsmnsyc
lxsmnsyc12mo ago
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
m5
m5OP12mo ago
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)
lxsmnsyc
lxsmnsyc12mo ago
you can. You just need to pass a ReadableStream to Response
m5
m5OP12mo ago
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?
Want results from more Discord servers?
Add your server