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. chrome - linux系统下如何通过java获取客户端ip和mac地址?2. java - Activity 进入后台再次传值?3. angular.js - ng-include 会缓存html吗?4. css - 手机app中rem的基准值计算错误5. javascript - sublime已经安装了babel插件和sublimelinter-jshint为什么还是显示es6语法错误?6. java - git项目迁移到SVN怎么实现的?哪位大神指点指点7. 前端 - 在webstrom上pull代码时出现错误?8. css如何实现图标和文字的“绝对对齐”呢?9. java - Spring boot项目 可以通过ip+port+contentPath就直接显示所有的接口地址和数据信息,这是为什么???10. css3的transform问题

网公网安备