title: 'no such file or directory': Download multiple files from S3
body: <p>I have an API method that when called and passed a string of file keys, converts that to an array, and downloads them from S3. However when I call this API, I get the error <code>Error: ENOENT: no such file or directory, open &lt;filename here&gt;</code> on the server.</p>
  
  <p>This is my api:</p>
  
  <pre><code>reports.get('/xxx/:fileName', async (req, res) =&gt; {
  
    var AWS = require('aws-sdk');
  
    var s3 = new AWS.S3();
  
    var str_array = req.params.fileName.split(','); 
  
    for (var i = 0; i &lt; str_array.length; i++) {
      var filename = str_array[i].trim();
      localFileName = './' + filename;
  
      let file = fs.createWriteStream(localFileName);   
  
      s3.getObject({
        Bucket: config.reportBucket,
        Key: filename
      })
      .on('error', function (err) {
        res.end("File download failed with error " + err.message);            
      })
      .on('httpData', function (chunk) {
        file.write(chunk);
      })
      .on('httpDone', function () {
        file.end();
      })
      .send();
    }
    res.end("Files have been downloaded successfully")
  });
  </code></pre>
  
  <p>How can I successfully download multiple files from S3 by passing my array of keys?</p>