使用回送存储容器在回送中上载文件时出错

时间:2018-09-18 18:01:52

标签: javascript node.js file-upload loopbackjs multer

我正在使用回送存储组件来存储任何上载的文件,并且正在使用multer解析多部分请求有效负载,但是当我从前端上载文件时,它没有上载到特定的容器中

  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;
    }
  };

这些是我在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());

当我点击api时,它会继续加载,一段时间后会出现此错误

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 个答案:

没有答案