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. 关于python爬虫的问题2. node.js - 在nodejs环境中如何配置webhook以实现hexo博客的自动更新?3. javascript - 为什么我的vue里的router-link不起作用4. css3 线性渐变实现间断线条效果5. node.js - win10如何安装并使用babel?6. javascript - weexpack编译出错 Cannot find module ’escape-string-regexp’7. css3 - 新版支付宝 账单页面滑动时月份栏被下一个月给顶上去是什么效果8. html5 - 用h5本地存储是否安全?9. 前端 - date属性的input文本框在微信上会出现奇怪的边框?10. javascript - 安装了babel,不起作用

网公网安备