node js загрузка файла "Запрос прерван" Сервер - PullRequest
0 голосов
/ 26 мая 2020

мой "Сервер" - это windows 10 станций ace mini p c. Устанавливаю на компьютер node js для закачки файла. Тестирую мультер, грозный, express -fileupload и многое другое. Я могу загрузить небольшой файл размером 3 МБ, но если я загружу большой файл, например 250 МБ, я получаю сообщение об ошибке.

Я думаю, что поток слишком быстрый для mini p c. Могу ли я справиться с этим?

Начинается загрузка, и через минуту я получаю сообщение об ошибке.

Ошибка: запрос прерван на IncomingMessage. (C: \ Filemanager \ node_modules \ formidable \ lib \ incoming_form. js: 122: 19) в IncomingMessage.emit (events. js: 315: 20) в abortIncoming (_http_server. js: 537: 9) в socketOnClose (_http_server. js: 530: 3) в Socket.emit (events. js: 327: 22) в TCP. (net. js: 671: 12)

const express = require('express');
const fileUpload = require('express-fileupload');
const app = express();

app.get('/', (req, res) => {
  res.send(`
    <h2>With <code>"express"</code> npm package</h2>
    <html>
    <body>
      <form ref='uploadForm' 
        id='uploadForm' 
        action='http://localhost:8000/upload' 
        method='post' 
        encType="multipart/form-data">
          <input type="file" name="sampleFile" />
          <input type='submit' value='Upload!' />
      </form>     
    </body>
  </html>
  `);
});

// default options
app.use(fileUpload());

app.post('/upload', function(req, res) {
  if (!req.files || Object.keys(req.files).length === 0) {
    return res.status(400).send('No files were uploaded.');
  }

  // The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file
  let sampleFile = req.files.sampleFile;

  // Use the mv() method to place the file somewhere on your server
  sampleFile.mv('/somewhere/on/your/server/filename.jpg', function(err) {
    if (err)
      return res.status(500).send(err);

    res.send('File uploaded!');
  });
});

startServer()

function startServer() {
  var port = 8888;
  server = app.listen(port, function () {
      console.log('Node version:' + process.versions.node);
      console.log('Express server listening on port %d in %s mode', port, app.settings.env);
  });

  server.on('connection', function(socket) {
      // 10 minutes timeout
      socket.setTimeout(10 * 60 * 1000);
  });
}

Спасибо за все идеи.

...