0

I need to add 100 files at a time using multer multiple file upload. For now 10 file's can be upload easly , but if I try to add more than 10 files it will throw an error like below,

Error: read ECONNRESET at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27) { message: 'read ECONNRESET', errno: 'ECONNRESET', code: 'NetworkingError', syscall: 'read', region: 'xx-xx-1', hostname: 'xxxxxxx.s3.amazonaws.com', retryable: true, time: 2020-08-05T05:52:39.950Z, statusCode: 400, storageErrors: [] }

Can you guys pla help , also I need to know the max count of files that multer accepts to upload, is there any way to set timeout for upload function only.

router.post('/files/fileuploads', upload.fields([{
  name: 'multi-files', maxCount: 100
}]), methods.multipleUpload)

const upload = multer({
  storage: multerS3({
    s3: s3,
    bucket: 'xxxxxx',
    metadata: function (req, file, cb) {
      cb(null, {fieldName: file.originalname});
    },
    key: function (req, file, cb) {
      
      cb(null, file.originalname)
    }
  }),
  fileFilter: fileFilter
});
aash
  • 1
  • 4

1 Answers1

0

If anyone needs help with this in the future, here's a blog post on how to upload 100 files at the same time through Node, even though the frontend is using Vue. The backend should be the same.

In the end what I think you should change is simply the backend route to be something like:

router.post("/files/fileuploads", upload.array('file', 101), async (req, res) => {
    return res.status(200).send('OK')
})
Anonymous User
  • 494
  • 4
  • 12