anacronw/multer-s3

multer-s3 code not executing sometimes

Closed this issue · 2 comments

Hi,

Please find the code i use to upload image in aws s3, its working fine most of the times but sometimes the piece of code to upload images in s3 in not getting executed, in those cases i see the console log 'Before calling aws s3' printed and not the log statement 'Inside callback method', also the images are not getting uploaded in s3 during this times.

Any idea why this happens? your suggestion is appreciated.

const uploadImageTest = multer({
              console.log("Before calling aws s3")
               storage: multerS3({
                   acl: 'public-read',
                   s3,
                   bucket: `test-bucket/image-test`,
                   key: function (req, file, cb) {
                       cb(null, `${Date.now().toString()}_${req.params.fileName}.jpg`)
                   }
               })
           }).single('image');

uploadImageTest(req, res, function (err) {
              console.log("Inside callback method")
               if (err) {
                   return res.status(422).send({ errors: [{ title: 'Error while uploading image', detail: err.message }] });
               }
               return res.json({ 'imageObject': req.file });
           });

did you figure this out.. I also have similar issues

I was getting the same issue, but i solved after install the Node LTS version. Check if you're using a LTS version of Node. I hope that helps you.