3

I want to resize and upload my images to s3 bucket.

I tried multer-s3-transform module and it didn't work.

And i tried sharp with it but it also didn't work.

const upload = multer({
  fileFilter: fileFilter,
  storage: multerS3({
    s3: s3,
    bucket: 'bucket',
    acl: 'public-read',
    shouldTransform: function(req, file, cb) {
      cb(null, /^image/i.test(file.mimetype));
    },
    transforms: [
      {
        id: 'original',
        transform: function(req, file, cb) {
          //Perform desired transformations
          cb(
            null,
            sharp()
              .resize(600, 600)
              .max()
          );
        }
      }
    ]
  })
});

0 Answers0