I have configured storage component of loopback successfully i.e. loopback-component-storage. I have been able to create folders. But when I try to upload files (using postman) it keeps giving request aborted error:
error: Error: Request aborted
at IncomingMessage.<anonymous> (E:\projects\TestProject\node_modules\formidable\lib\incoming_form.js:120:19)
at emitNone (events.js:86:13)
at IncomingMessage.emit (events.js:185:7)
at abortIncoming (_http_server.js:283:11)
at TLSSocket.serverSocketCloseListener (_http_server.js:296:5)
at emitOne (events.js:101:20)
at TLSSocket.emit (events.js:188:7)
at _handle.close (net.js:498:12)
at Socket.done (_tls_wrap.js:325:7)
at Socket.g (events.js:291:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at TCP._handle.close [as _onclose] (net.js:498:12)
I have also configured SSL, so the url is https://localhost/api/containers/container1/upload. Could this be an issue ? I am using the following modules in my package.json.
"dependencies": {
"body-parser": "^1.17.1",
"compression": "^1.6.2",
"cors": "^2.8.1",
"express": "^4.15.2",
"helmet": "^3.4.1",
"js2xmlparser": "^3.0.0",
"loopback": "^3.4.0",
"loopback-boot": "^2.23.0",
"loopback-component-explorer": "^4.1.1",
"loopback-component-storage": "^3.2.0",
"loopback-connector-rest": "^2.1.0",
"loopback-datasource-juggler": "^3.2.0",
"loopback-ssl": "0.0.9",
"multer": "^1.3.0",
"strong-error-handler": "^2.1.0",
"winston": "^2.3.1"
}
The server.js file looks like below:
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
var loopbackSSL = require('loopback-ssl');
var bodyParser = require('body-parser');
var multer = require('multer');
var app = module.exports = loopback();
app.use(bodyParser.text());
app.start = function () {
// start the web server
return app.listen(function () {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function (err) {
if (err) throw err;
if (require.main === module)
return loopbackSSL.startServer(app);
});
Could any of the above modules be an issue ? Looks like this is a node-formidable issue. Could anyone let me know ? Can we write a remote method to accept files ?
I have been able to fix this issue by removing
app.use(bodyParser.text());
from server.js. The files are getting uploaded now.