【发布时间】:2016-05-24 10:59:32
【问题描述】:
我正在尝试编写一个从服务器返回到客户端响应的缓冲区。
因此,我定义了一个路由,用于在action 函数上获取文件:
Router.route('/download/:blabla', {
name: 'download',
action: function () {
var that = this.response;
Meteor.call('downloadFile', blabla, function (err, result) {
// error check etc.
var headers = {
'Content-type' : 'application/octet-stream',
'Content-Disposition' : 'attachment; filename=' + fileName
};
that.writeHead(200, headers);
that.end(result);
}
}
});
这会抛出:
调用“downloadFile”的结果传递异常:TypeError: that.writeHead 不是函数
没有 Metoer.call 它可以工作...
我正在使用 nodejs 流在服务器端函数上获取缓冲区,它可以工作。
提前致谢
【问题讨论】:
-
你为什么不尝试设置
var that = this和that.response.writeHead(...) -
它也没有帮助
标签: javascript node.js meteor iron-router