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. python文檔怎么查看?2. python - pycharm 自動刪除行尾空格3. 安全性測試 - nodejs中如何防m(xù)ySQL注入4. python - pandas按照列A和列B分組,將列C求平均數(shù),怎樣才能生成一個列A,B,C的dataframe5. python - Pycharm的Debug用不了6. html - eclipse 標簽錯誤7. python 利用subprocess庫調(diào)用mplayer時發(fā)生錯誤8. 請問PHPstudy中的數(shù)據(jù)庫如何創(chuàng)建索引9. datetime - Python如何獲取當前時間10. javascript - 有適合開發(fā)手機端Html5網(wǎng)頁小游戲的前端框架嗎?
