node.js - nodejs如何发送请求excel文件并下载
问题描述
问题解答
回答1:res.download(path [, filename] [, fn]) http://expressjs.com/en/api.h...Transfers the file at path as an “attachment”. Typically, browsers will prompt the user for download. By default, the Content-Disposition header “filename=” parameter is path (this typically appears in the browser dialog). Override this default with the filename parameter.
When an error ocurrs or transfer is complete, the method calls the optional callback function fn. This method uses res.sendFile() to transfer the file.
res.download(’/report-12345.pdf’);res.download(’/report-12345.pdf’, ’report.pdf’);res.download(’/report-12345.pdf’, ’report.pdf’, function(err){ if (err) { // Handle error, but keep in mind the response may be partially-sent // so check res.headersSent } else { // decrement a download credit, etc. }});
相关文章:
1. Chrome-org.openqa.selenium.WebDriverException:未知错误:无法在driver.manage()window()maximize();处获得自动化扩展2. python - celery 如何解决worker和client代码同步问题3. python开发的脚本想上个ui,用哪个库来绘制窗口比较好?求推荐4. sublime text 3不支持python的input吗5. 紧急求助-我们的一位同事突然离职,需要一个后端的同事,项目才能进行,停滞了,那位可以帮帮忙?6. mysql查询数据并不是输入数据7. python对8000行csv添加列8. python - Win7调用flup报错’module’ object has no attribute ’fromfd’9. python执行cmd命令,怎么让他执行类似Ctrl+C效果将其结束命令?10. python - 如何使用websocket在网页上动态示实时数据的折线图?

网公网安备