I have a route that sends a pdf file:
app.get('/teste',function(req,res,next){ res.setHeader('content-type','application/pdf'); res.download(app.get('appPath')+'/teste.pdf'); }
I tried using other solutions that do more or less the same thing:
app.get('/teste',function(req,res,next){ res.setHeader('content-type','application/pdf'); fs.createReadStream(app.get('appPath')+'/teste.pdf').pipe(res); }
and
app.get('/teste',function(req,res,next){ res.setHeader('content-type','application/pdf'); res.sendfile(app.get('appPath')+'/teste.pdf'); }
My problem is when I ask for this route in the browser and I get an empty PDF file with the same number of pages as the original file.
I configured my express server using app.use(express.bodyParser()); .
Can anybody help me?
user2542231
source share