How to pipe stream/buffer to new Response objects?
Answered
Griffon Nivernais posted this in #help-forum
Griffon NivernaisOP
Originally I was able to pipe to
NextApiResponses, as Next moves in the direction of working with the new Response, I'm struggling to understand how I can pipe a stream from say React PDF over to the response.Answered by Griffon Nivernais
6 Replies
Griffon NivernaisOP
I did try something like the following but I believe it's being read literally by the interpreter, as it starts saying things like
<arbitrary characters> is not a constructorreturn new Response(stream.read(), {
headers: {
"Content-Type": "application/pdf",
},
status: 200,
});A stream is normally made in React PDF via
const stream: ReadableStream = await ReactPDF.renderToStream(
<JSX />
);Griffon NivernaisOP
There was also a
ReactPDF.renderToBuffer() option but unsure how to utilise the returned Buffer eitherGriffon NivernaisOP
Bump.
Griffon NivernaisOP
Bump.
Griffon NivernaisOP
Answer