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. angular.js - 百度支持_escaped_fragment_吗?2. javascript - vue $set 整个数组3. docker-compose中volumes的问题4. vim - win10无法打开markdown编辑器5. 新手 - Python 爬虫 问题 求助6. 微信开放平台 - ios APP能不能打开微信然后通过微信跳转到指定的URL?7. php mail无法发送邮件8. thinkphp5.1学习时遇到session问题9. python - 管道符和ssh传文件10. css - 移动端 line-height安卓错位,苹果机正常用,缩放解决了,可是又出来了占位的问题
