How to make binary data response #561
Replies: 1 comment
-
This works const pdfData = ......
res.setHeader("Content-Type", "application/pdf");
let stream = new Duplex();
stream.push(pdfData);
stream.push(null);
stream.pipe(process.stdout);
await new Promise(function (resolve) {
stream.pipe(res);
stream.on("end", resolve);
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to make a pdf download API.
My api decleration like this.
I have changing contet-type in api implementation function but getting alloways application-json also responses as
{"0":37,"1":80,"2":68,"3":70,"4":45,"5":49,"6":46,"7".....
What is the correct way for binary responses.
Beta Was this translation helpful? Give feedback.
All reactions