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. windows误人子弟啊2. 冒昧问一下,我这php代码哪里出错了???3. MySQL主键冲突时的更新操作和替换操作在功能上有什么差别(如图)4. python - linux怎么在每天的凌晨2点执行一次这个log.py文件5. 数据库 - Mysql的存储过程真的是个坑!求助下面的存储过程哪里错啦,实在是找不到哪里的问题了。6. 实现bing搜索工具urlAPI提交7. mysql优化 - MySQL如何为配置表建立索引?8. 如何用笔记本上的apache做微信开发的服务器9. 我在网址中输入localhost/abc.php显示的是not found是为什么呢?10. 关于mysql联合查询一对多的显示结果问题
