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. linux - 阿里云服务器上的mysql服务在客户端只能通过ssh证书连接后才能使用3. python - pip install出现下面图中的报错 什么原因?4. (python)关于如何做到按win+R再输入文件文件名就可以运行?5. 登录mysql-front出现以下错误6. 急急国王什么梗 我是急急急急急急国王梗内涵出处介绍7. 微博2输入框一些问题8. python html如何转成PDF?9. mysql - 博客文章标签表结构设计问题10. python - 图片爬虫时候遇到问题 urllib.request.urlretrieve 下载到指定文件夹不成功?

网公网安备