title: How do I restrict file types to images only using multerS3?
body: <p>I have been able to connect my S3 bucket to my web application using multerS3, however, I'm not sure how to go about restricting the files that can be uploaded to images only. Before I was using S3, I used multerFilter to check the mime type, and that worked. However, now, using the same code, it seems like any type of file will be uploaded to my S3 bucket. What's the best way to restrict file types to images with multerS3? Thank you.</p>
  <pre><code>const multerFilter = (req, file, cb) =&gt; {
    if (file.mimetype.startsWith('image')) {
      cb(null, true);
    } else {
      cb(new AppError('Not an image! Please upload images only.', 400), false);
    }
  };
  
  const upload = multer({
    storage: multerS3({
      s3: s3,
      acl: 'public-read',
      bucket: 'BUCKET NAME',
      contentType: multerS3.AUTO_CONTENT_TYPE,
      fileFilter: multerFilter,
    }),
  });
  </code></pre>