I tired to uplaod a 7G tar file to my server (via postman) but failed.
I tried to upload same file several times, and my server only recieved 2.8G everytime (spend about 12-15 minutes) then postman's request got some error like read ECONNRESET, write EPIPE.
And my server got an error Unexpected end of multipart data, this error is evoked by multer package.
what I have tried?
After google the errors, it seems like the problem of
connection between client and server disruptI also tried to upload a 3.5G video (because server only recived 2.8G in my question), then it succeed and spend 19 minutes!!
Then I tar that 3.5G video, and upload it again. Also succeed!
My summary and How can I do?
In beginning, I think the problem is about request timeout, upload directory storage limit, tar file limitation or multer package problem.
But upload the video (and its tar file) spend more than 12-15 minutes, so it seems not the timeout problem. And also not the tar file problem.
And the 3.5G video (and its tar file) can be saved in the directory, so it is not the storage limitation problem.
I execute same code in macOS, and it can uplaod that 7G file!! So, it seems not the problem about multer package.
I have no idea how to solve this problem. Anyone can help me?
My code
const express = require('express')
const multer = require('multer')
const http = require('http')
const app = express()
const server = require('http').Server(app)
const PORT = 5568
const uploader = multer({ dest: '/tmp' }).single('file')
app.post('/upload', (req, res) => {
uploader(req, res, (err) => {
if (err) {
console.log('errrrrr');
console.log(err);
return res.status(400).json(err)
}
console.log('upload finish!!!')
return res.status(200).json(req.file)
})
})
server.listen(PORT, () => {
console.log(server is running at ${PORT} ...)
})