node.js - express.js: how to download stream as a file? -



node.js - express.js: how to download stream as a file? -

my story follows: user uploads txt file express.js server, text file transformed pdf file; pdf file can streamed browser via request.pipe. can stream on user side, how allow browser download stream pdf file?

if have pdf readable stream, can like:

res.attachment('pdfname.pdf'); pdfstream.pipe(res);

or if have pdf on disk, can send client with:

res.download('/path/to/file.pdf');

or specify custom filename that's presented browser:

res.download('/path/to/file.pdf', 'pdfname.pdf');

node.js express

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -