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. mysql sql where id in(25,12,87) 结果集如何用按照 25 12 87排序?2. mysql优化 - mysql 分页查询优化。3. python中merge后文件莫名变得非常大4. javascript - 请问这段 el && fn.call(el, e, el)代码这么写什么意思?5. javascript - 请教,用原生js插入html的问题6. linux - python 安装 Anaconda 环境变量问题请教7. python3.x - python多线程如何修改数据?8. mysql连表排序9. mysql插入文本如果是个sql语句就报错了10. mysql - SQL添加记录的数据来源于同一个表

网公网安备