title: Nodejs - how to upload file from req to aws s3
body: <p>Working on web-app: React &amp; Node.</p>
  <p>the client app sends file to the server, and the server should upload it to an <code>S3 bucket</code>.</p>
  <p>using <code>import S3 from 'aws-sdk/clients/s3';</code> i found the <code>upload</code> function.</p>
  <p>The <code>upload</code> function expect to get Buffer or Stream, and i don't know how to convert the file to buffer/stream.</p>
  <p><strong>Code</strong></p>
  <pre><code>app.get('/upload', (req, res) =&gt; {
     const { file } = req;
     s3.upload({ Bucket: 'MY_BUCKET', Key: 'MY_KEY', Body: streamifyFile(file)});
  })
  
  const streamifyFile = () =&gt; {
     // how to implement
  }
  </code></pre>