【发布时间】:2012-12-03 08:37:34
【问题描述】:
我可以获得我请求的文件的原始数据,但我无法让浏览器将文件提供给用户。我需要使用 iframe 吗?
//Client code
download_file: function (path, callback) {
$http.post('/download/client_file', {path:path}).
success(function(data, status, headers, config) {
console.log(data); //this contains the raw data of the res.download
//from the server.
});
}
//server code
res.download(file); // the path is proper
【问题讨论】:
-
使用 HTTP GET 会更好吗? (也就是模拟用户点击文件链接时会发生什么)
-
无论我使用 GET 还是 POST 都没有关系,我只是没有正确的表单数据对象。
标签: download express angularjs