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. 我在centos容器里安裝docker,也就是在容器里安裝容器,報錯了?2. docker-compose中volumes的問題3. docker不顯示端口映射呢?4. golang - 用IDE看docker源碼時的小問題5. 在windows下安裝docker Toolbox 啟動Docker Quickstart Terminal 失敗!6. docker容器呢SSH為什么連不通呢?7. javascript - 最近用echarts做統計圖時遇到兩個問題!!8. mac里的docker如何命令行開啟呢?9. javascript - 連續點擊觸發mouseleave事件10. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””

網公網安備