title: How can i compress image size with multer on upload?
body: <p>How can i make compression on image size on upload, i will have a lot of files in my S3 bucket so i need this.</p>
  <p>How can i transofrm this code do to that ?</p>
  <pre><code>
  app.post('/api/v1/upload', upload.array('image', 1), (req, res) =&gt; {
    res.send({ image: req.file });
  });
  
  
  aws.config.update({
    secretAccessKey: process.env.SECRET_ACCESS_KEY,
    accessKeyId: process.env.ACCESS_KEY_ID,
    region: 'us-east-1' //E.g us-east-1
  });
  
  const s3 = new aws.S3();
  
  
  const fileFilter = (req, file, cb) =&gt; {
    if (file.mimetype === 'image/jpeg' || file.mimetype === 'image/png') {
      cb(null, true);
    } else {
      cb(new Error('Invalid file type, only JPEG and PNG is allowed!'), false);
    }
  };
  
  
  const upload = multer({
    fileFilter: fileFilter,
    storage: multerS3({
      acl: 'public-read',
      s3,
      bucket: 'oldst123',
      key: function(req, file, cb) {
        req.file = file.originalname;
        cb(null, file.originalname);
      }
    })
  });
  </code></pre>