title: How to send multiple files to AWS S3 using Multer-S3 from different fields
body: <p>I'm currently using Postman in which I require to upload two files from two different fields to AWS-S3; this is how it looks like:
  <a href="https://i.stack.imgur.com/mcVI2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mcVI2.jpg" alt="enter image description here" /></a>
  This is the API route that I'm calling:</p>
  <pre><code>router.route('/').post(uploadThumbnail, uploadVideo, createVideo);
  </code></pre>
  <p>That route calls three functions(which is supposed to return the data requested from Postman):</p>
  <pre><code>exports.createVideo = asyncHandler(async (req, res, next) =&gt; {
    // Add user to req,body
    req.body.user = req.user.id;
    // Bring files
    if (req.file) {
      console.log(req.file);
    }
  });
  </code></pre>
  <p>Here are the two other functions(with the aws upload function); one for thumbnail and a second one for video_url:</p>
  <pre><code>const upload = multer({
    storage: multerS3({
      s3: s3,
      bucket: process.env.AWS_BUCKET_NAME,
      acl: 'public-read',
      key: function(req, file, cb) {
        const strOne = process.env.WEBSITE_NAME + '-';
        const userId = req.user.id + '-';
        const userEmail = req.user.email + '-';
        const todaysDate = Date.now().toString() + '.';
        const extension = file.mimetype.split('/')[1];
        const finalStr = strOne.concat(userId, userEmail, todaysDate, extension);
        cb(null, finalStr);
      }
    })
  });
  exports.uploadThumbnail = upload.single('thumbnail');
  exports.uploadVideo = upload.single('video_url');
  </code></pre>
  <p>Everytime I run the post, Postman throws me this error:</p>
  <pre><code>{
      &quot;status&quot;: &quot;error&quot;,
      &quot;error&quot;: {
          &quot;name&quot;: &quot;MulterError&quot;,
          &quot;message&quot;: &quot;Unexpected field&quot;,
          &quot;code&quot;: &quot;LIMIT_UNEXPECTED_FILE&quot;,
          &quot;field&quot;: &quot;video_url&quot;,
          &quot;storageErrors&quot;: [],
          &quot;statusCode&quot;: 500,
          &quot;status&quot;: &quot;error&quot;
      },
      &quot;message&quot;: &quot;Unexpected field&quot;,
      &quot;stack&quot;: &quot;MulterError: Unexpected field\n    at wrappedFileFilter (C:\\xampp\\htdocs\\myporn\\node_modules\\multer\\index.js:40:19)\n    at Busboy.&lt;anonymous&gt; (C:\\xampp\\htdocs\\myporn\\node_modules\\multer\\lib\\make-middleware.js:114:7)\n    at Busboy.emit (events.js:198:13)\n    at Busboy.EventEmitter.emit (domain.js:448:20)\n    at Busboy.emit (C:\\xampp\\htdocs\\myporn\\node_modules\\busboy\\lib\\main.js:38:33)\n    at PartStream.&lt;anonymous&gt; (C:\\xampp\\htdocs\\myporn\\node_modules\\busboy\\lib\\types\\multipart.js:213:13)\n    at PartStream.emit (events.js:198:13)\n    at PartStream.EventEmitter.emit (domain.js:448:20)\n    at HeaderParser.&lt;anonymous&gt; (C:\\xampp\\htdocs\\myporn\\node_modules\\dicer\\lib\\Dicer.js:51:16)\n    at HeaderParser.emit (events.js:198:13)\n    at HeaderParser.EventEmitter.emit (domain.js:448:20)\n    at HeaderParser._finish (C:\\xampp\\htdocs\\myporn\\node_modules\\dicer\\lib\\HeaderParser.js:68:8)\n    at SBMH.&lt;anonymous&gt; (C:\\xampp\\htdocs\\myporn\\node_modules\\dicer\\lib\\HeaderParser.js:40:12)\n    at SBMH.emit (events.js:198:13)\n    at SBMH.EventEmitter.emit (domain.js:448:20)\n    at SBMH._sbmh_feed (C:\\xampp\\htdocs\\myporn\\node_modules\\streamsearch\\lib\\sbmh.js:159:14)\n    at SBMH.push (C:\\xampp\\htdocs\\myporn\\node_modules\\streamsearch\\lib\\sbmh.js:56:14)\n    at HeaderParser.push (C:\\xampp\\htdocs\\myporn\\node_modules\\dicer\\lib\\HeaderParser.js:46:19)\n    at Dicer._oninfo (C:\\xampp\\htdocs\\myporn\\node_modules\\dicer\\lib\\Dicer.js:197:25)\n    at SBMH.&lt;anonymous&gt; (C:\\xampp\\htdocs\\myporn\\node_modules\\dicer\\lib\\Dicer.js:127:10)\n    at SBMH.emit (events.js:198:13)\n    at SBMH.EventEmitter.emit (domain.js:448:20)\n    at SBMH._sbmh_feed (C:\\xampp\\htdocs\\myporn\\node_modules\\streamsearch\\lib\\sbmh.js:188:10)\n    at SBMH.push (C:\\xampp\\htdocs\\myporn\\node_modules\\streamsearch\\lib\\sbmh.js:56:14)\n    at Dicer._write (C:\\xampp\\htdocs\\myporn\\node_modules\\dicer\\lib\\Dicer.js:109:17)\n    at doWrite (_stream_writable.js:415:12)\n    at writeOrBuffer (_stream_writable.js:399:5)\n    at Dicer.Writable.write (_stream_writable.js:299:11)&quot;
  }
  </code></pre>
  <p>The function works great but only when sending one single file, it can be either thumbnail or video_url but not both...I need both fields to work.</p>
  <p>Any idea on how to fix this?</p>