I try to return some binary data with Express. In the example, it's a PDF but theorically, this can be any sort of file.
But focus on the pdf for the moment. I wrote this code :
app.get('*', function (req, res) {
getBinaryData(req.url,
function (answer) {
res.type('pdf');
res.end(new Buffer(answer, 'binary'));
},
function (error) {
res.setHeader('Content-Type', 'text/plain');
return res.end(error);
}
);
});
Based on what I saw here : https://github.com/strongloop/express/issues/1555
But, i get a pdf file with the right number of pages, right title.... but all the pages are blank
I'm sure concern the return of getBinaryData(), because this function asked an external Web Service and when I asked directly this service, I got the right document.
Thank you in advance for your answers
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…