Thursday, 15 July 2010

node.js - Express .sendFile only works in chrome -


I want to send a PDF file to the client, with it I Express from Send Express I do a great job in Chrome, the download link saves it with Chrome, with a normal link, Chrome opens it in a new Chrome tab.

But in Mozilla, Safari and IE, the browser displays a message "File is damaged" or Adobe Reader Adobe Reader does not show this message when PDF is loaded on Chrome.

My code:

  app.get ('/ ebooks /: file', function ({'X-timestamp': Date.now (), 'x- Sent ': true,' content- ',' content-type ':' application / pdf '}}; var filename = req.params.file; res.sendFile (filename, option, function (error) {if (err) {Console.log (err); res.status (err .status) .end ();} else {console.log ('sent:', filename);}});});  

Why does anyone have an idea?

Varha

I had only one issue, but I turned into res.download and it worked fine. The behavior in Chrome is not as beautiful, but it's Has been completed. This experience is interested to see that with anyone else PDF is the best solution.


No comments:

Post a Comment