Error in uploading file in loopback using loopback storage container

Viewed 190

I am using loopback storage component for storing any uploaded file and I am using multer to parse multipart request payload but when I am uploading file from frontend it is not uploading to particular container

  Account.uploadCASStatement = function (req, res, filePassword, panNumber, callback) {
    let container = 'casstatements';
    console.log(filePassword);
    const promise = new Promise(function (resolve, reject) {
      Account.app.models.FileStorageContainer.upload(container, req, res)
        .then(() => resolve({ success: true }))
        .catch(reject);
    });
    if (callback !== null && typeof callback === 'function') {
      promise.then(function (data) { return callback(null, data); }).catch(function (err) { return callback(err); });
    } else {
      return promise;
    }
  };

and these are the parsers which I am using in server.js

app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
// app.use(multer({ dest: __dirname + '/.tmp/' }).any());// for parsing multipart/form-data
app.use(multer().any());

when I hit the api it keeps on loading and after some time it gives this error

Request aborted
    at IncomingMessage.<anonymous> (/Users/vikas/valuefy/wealthfy/node_modules/formidable/lib/incoming_form.js:122:19)
    at IncomingMessage.clsBind (/Users/vikas/valuefy/wealthfy/node_modules/cls-hooked/context.js:172:17)
    at emitNone (events.js:106:13)
    at IncomingMessage.emit (events.js:208:7)
    at IncomingMessage.emitted (/Users/vikas/valuefy/wealthfy/node_modules/emitter-listener/listener.js:134:21)
0 Answers
Related