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. html5 - 在一个页面中 初始了两个swiper 不知道哪里错了 一直不对2. javascript - 如何将 windows 下编辑器中的 CRLF 替换为 LF?3. javamail发送邮件是否跟所在的网络环境有关?4. javascript - 求解答:实例对象调用constructor,此时constructor内的this的指向?5. Windows系统能否利用Docker使用Ubuntu吗?Ubuntu能使用本机的显卡吗?6. 请教,关于python字典,合并相同值的键的实现方法7. mysql5.7就没有官方性质的详细配置文件吗?求大神告知8. android - 京东移动端网页和其app加载的url所做的呈现不应该是完全一样的吗?9. css3中translate(-50%,-50%)对 transform-origin的奇葩影响?10. python的MySQLdb库中的executemany方法如何改变默认加上的单引号?

网公网安备