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. java - 针对MongoDB当前哪个第三方ORM框架更稳定成熟?2. python - 两千万条结构化数据怎么进行数据分析3. java - mybatis怎么实现在数据库中有就修改,没有就添加4. javascript - weex和node,js到底是怎样一个关系呢?5. node.js - vue-cli项目不知名报错,求解6. javascript - npm run build后调用api返回index.html7. thinkphp5.1学习时遇到session问题8. transform - CSS3的3D变换多次变换如何保持坐标轴不动,或者有矩阵算法可以实现否9. javascript - 微信小程序 如何实现这种左滑动出现删除的办法?有相关api吗?10. python - pandas中mode()怎么使用?
