【发布时间】:2017-03-06 14:01:26
【问题描述】:
我有一个非常简单的服务器在环回 3 下运行并再次看到这个问题:https://github.com/strongloop/loopback-component-storage/issues/9
由于要点和示例不再适用,我想重新打开该问题。 我创建了一个非常简单的 API 模板服务器并添加了以下代码:
module.exports = function (File) {
File.upload = function (ctx, options, cb) {
if (!options) options = {};
ctx.req.params.container = 'common';
console.log("DO");
File.app.models.Storage.upload(ctx.req, ctx.result, options, function (err, fileObj) {
console.log("FILE");
cb(fileObj);
});
};
File.remoteMethod(
'upload',
{
description: 'Uploads a file',
accepts: [
{arg: 'ctx', type: 'object', http: {source: 'context'}},
{arg: 'options', type: 'object', http: {source: 'query'}}
],
returns: {
arg: 'fileObject', type: 'object', root: true
},
http: {verb: 'post'}
}
);
};
现在的问题是,在通过 POSTMAN 发布到上传功能时,我在控制台中看到以下行为:
DO
Error: Request aborted
at IncomingMessage.<anonymous> (...../server/node_modules/formidable/lib/incoming_form.js:120:19)
at emitNone (events.js:86:13)
at IncomingMessage.emit (events.js:188:7)
at abortIncoming (_http_server.js:383:9)
at socketOnClose (_http_server.js:377:3)
at emitOne (events.js:101:20)
at Socket.emit (events.js:191:7)
at TCP._handle.close [as _onclose] (net.js:504:12)
FILE
邮递员返回一个空响应...
作为初学者,我在这一步完全迷失了!
这是我的错吗?
感谢任何输入
【问题讨论】:
标签: node.js loopbackjs