title: Upload file to aws S3 bucket using absolute path
body: <p>I am trying to upload files from Express ejs to AWS s3 bucket I am successful in doing so but when I am trying to select files from other directory or folder other than where my index.js is it doesn't accept the file and throw error file not found.</p>
  <p><strong>index.js</strong></p>
  <pre class="lang-js prettyprint-override"><code>
  
  'use strict';
  
  const express = require('express');
  const app = express();
  const multer  = require('multer');
  const multerS3 = require('multer-s3');
  const AWS = require('aws-sdk');
  const bodyParser = require('body-parser');
  
  const s3 = new AWS.S3({
      accessKeyId: '',
      secretAccessKey: ''
  });
  
  app.use(bodyParser.urlencoded({extended : true})); 
  app.set('view engine', 'ejs'); 
  
  
  
  const uploadS3 = multer({
    storage: multerS3({
      s3: s3,
      bucket: '',
      metadata: (req, file, cb) =&gt; {
        cb(null, {fieldName: file.fieldname})
      },
      key: (req, file, cb) =&gt; {
        cb(null, Date.now().toString() + '-' + file.originalname)
      }
    })
  });
  </code></pre>
  <p><strong>test.ejs</strong></p>
  <pre class="lang-html prettyprint-override"><code>&lt;html&gt;
    &lt;form method=&quot;post&quot; action=&quot;/upload&quot;&gt;
      &lt;input type=&quot;file&quot; name=&quot;file&quot; /&gt;
      &lt;input type=&quot;submit&quot; /&gt;
    &lt;/form&gt;
  &lt;/html&gt;
  </code></pre>
  <p><strong>route.js</strong></p>
  <pre><code>
  var fileupload = require('../../common/service/file-upload');
  //some code in between 
  
  app.post('/upload', fileupload.uploadS3.single('file'),(req, res) =&gt; {
    console.log(req.file);
  });
  
  
  </code></pre>