node.js - nodejs如何發(fā)送請求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. }});
相關(guān)文章:
1. docker容器呢SSH為什么連不通呢?2. 關(guān)docker hub上有些鏡像的tag被標記““This image has vulnerabilities””3. docker網(wǎng)絡(luò)端口映射,沒有方便點的操作方法么?4. nignx - docker內(nèi)nginx 80端口被占用5. debian - docker依賴的aufs-tools源碼哪里可以找到啊?6. 前端 - ng-view不能加載進模板7. android clickablespan獲取選中內(nèi)容8. python - from ..xxxx import xxxx到底是什么意思呢?9. javascript - iframe 為什么加載網(wǎng)頁的時候滾動條這樣顯示?10. angular.js - ng-grid 和tabset一起用時,grid width默認特別小
