【发布时间】:2014-12-06 03:55:35
【问题描述】:
我正在使用Loopback storage service 进行文件上传,它工作正常。 我想对上传的文件进行后期处理,所以我添加了远程挂钩方法 beforeRemote 和 afterRemote。当我使用 '*' 作为方法名称时,它可以工作。当我将其更改为 'upload' 或 'container.upload' 或其他任何内容时,它会停止工作。 甚至 afterSave 也不会被容器调用。
module.exports = function(Container) {
Container.beforeRemote('*.upload', function(ctx, unused, next) {
if(ctx.req.accessToken) {
console.log('beforeCalled with token');
next();
} else {
console.log('beforeCalled no token');
next();
}
});
Container.afterRemote('*.upload', function(ctx, user, next) {
console.log("file uploaded", user.result.files);
next();
});
Container.beforeSave = function(next, modelInstance) {
console.log("beforeSave:", modelInstance );
next();
};
};
我错过了什么吗?应该怎么做?
【问题讨论】:
标签: loopbackjs strongloop