【发布时间】:2014-11-21 08:56:12
【问题描述】:
我正在尝试将reply.file (http://hapijs.com/api#replyfilepath-options) 用作server.method (http://hapijs.com/api#servermethodname-fn-options),但它说我的next 函数没有file:
Debug: hapi, internal, implementation, error
TypeError: Uncaught error: Object function (err, result) {
methodNext(err, result, null, { msec: timer.elapsed(), error: err });
} has no method 'file'
at /Users/user/Work/Dev/export.js:37:12
at ChildProcess.<anonymous> (/Users/user/Work/Dev/node_modules/webshot/lib/webshot.js:221:9)
at ChildProcess.emit (events.js:98:17)
at Process.ChildProcess._handle.onexit (child_process.js:810:12)
我有以下几点:
server.method('getExport', function(reqParams, queryParams, hostUri, next) {
// ...
next.file(filePath, {
// Download as an attachment
mode: 'attachment'
});
});
Instance.server.route({
method: 'GET',
path: '/export',
config: {
handler: function(req, reply) {
var uri = req.server.info.uri;
server.methods.getExport(
req.params,
req.query,
uri,
reply
);
}
}
});
有可能吗?
我正在使用 hapi v6.9。
【问题讨论】: