I've a very simple server running under loopback 3 and seeing this issue again: https://github.com/strongloop/loopback-component-storage/issues/9
As the gists and examples don't work any longer I would like to reopen that issue. I've created a very simple API templated server and added the following code:
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'}
}
);
};
The problem is now, that while posting via POSTMAN to the upload function, I see the following behavior in the console:
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
And Postman returns an empty response...
I'm totally lost as a beginner here at this step!
What is my fault here?
Thx for any input