上传文件 SailsJS

Upload file SailsJS

我正在尝试从 VueJS 网络应用程序将文本文件上传到服务器 运行 SailsJS。我能够确认 VueJS 正在发送文件,但我在服务器上不断收到错误消息。我的代码如下:

uploadData(req, res) {
  Logger.info(req.file('file'));

  req.file('file').upload({
    dirname:'../../tmp',
    saveAs:"hello"
  },function onUploadComplete(err,files){
    if(err){
      console.log(err);
      return res.serverError(err);
    }
    if(!files.length) {
      return res.serverError(new Error('No file Uploaded'))
    }
    res.ok(files);
  });
},

我得到的错误如下:

2018-09-17T16:55:07.736Z] info:  info: Custom response `res.serverError()` called with an Error: Error: Request aborted
    at IncomingMessage.onReqAborted (/home/ubuntu/server/node_modules/multiparty/index.js:183:17)
    at IncomingMessage.emit (events.js:182:13)
    at IncomingMessage.EventEmitter.emit (domain.js:442:20)
    at abortIncoming (_http_server.js:444:9)
    at socketOnClose (_http_server.js:437:3)
    at Socket.emit (events.js:187:15)
    at Socket.EventEmitter.emit (domain.js:442:20)
    at TCP._handle.close (net.js:599:12)

我做错了什么?我按照以下说明进行操作:

https://sailsjs.com/documentation/reference/request-req/req-file

https://sailsjs.com/documentation/concepts/file-uploads

这是有效的:

uploadData(req, res) {
  Logger.info(req.file('file'));

  return req.file('file').upload({
    adapter: require('skipper-disk'),
    saveAs:"hello"
  },function onUploadComplete(err,files){
    if(err){
      console.error("ERROR");
      console.log(err);
      return res.serverError(err);
    }
    if(!files.length) {
      return res.serverError(new Error('No file Uploaded'))
    }
    res.ok(files);
  });
},