-
Hi, I am currently trying out the wonderful little package and trying to figure out how to return a binary stream and use and input object. My example is an pdf to image converter where the request body is the pdf and formatting parameters are passed via query. The result is an binary image. From what I read in the docs I should use an EndpointsFactory with positive and negative response for that. But then how to use an zod input object with that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello, @lanwin . In order to receive the whole request body as a binary stream, see raw data processing: If possible, consider also regular file uploads instead: In order to stream the image in response, see the example of custom ResultHandler:
I hope I managed to help you. Please let me know if something need to be clarified. |
Beta Was this translation helpful? Give feedback.
Hello, @lanwin .
In order to receive the whole request body as a binary stream, see raw data processing:
https://github.com/RobinTail/express-zod-api#accepting-raw-data
If possible, consider also regular file uploads instead:
https://github.com/RobinTail/express-zod-api#file-uploads
In order to stream the image in response, see the example of custom ResultHandler:
https://github.com/RobinTail/express-zod-api#non-object-response
ez.raw()
which is an alias forz.object({ raw: z.file().buffer() })
— you will need to adjust you config withrawParser
option in order to make this little trick work. This feature …