title: "Missing credentials in config" while trying to stream a file to Amazon S3 bucket in node.js
body: <p>I tried to setup a basic file stream to Amazon S3.
  I copied and pasted the example on
  <a href="https://www.npmjs.com/package/s3-upload-stream" rel="nofollow">https://www.npmjs.com/package/s3-upload-stream</a></p>
  
  <p>And modified it slightly (as attached).</p>
  
  <pre><code>   var AWS = require('aws-sdk'),
     zlib = require('zlib'),
     s = require('fs');
     s3Stream = require('s3-upload-stream')(new AWS.S3()),
  
          // Set the client to be used for the upload.
          AWS.config.loadFromPath('./config.json');
  
  
      // Create the streams
      var read = fs.createReadStream('path to a file');
      var compress = zlib.createGzip();
      var upload = s3Stream.upload({
          "Bucket": "bucketName",
          "Key": "file.txt"
      });
  
      module.exports = function (router) {
          router.get('/', function (req, res) {
              res.render('upload')
          })
          router.post('/', function (req, res) {
              // Handle errors.
              upload.on('error', function (error) {
                  console.log(error);
              });
  
  
              /* Handle progress. Example details object:
               { ETag: '"f9ef956c83756a80ad62f54ae5e7d34b"',
               PartNumber: 5,
               receivedSize: 29671068,
               uploadedSize: 29671068 }
               */
              upload.on('part', function (details) {
                  console.log(details);
              });
  
  
              /* Handle upload completion. Example details object:
               { Location: 'https://bucketName.s3.amazonaws.com/filename.ext',
               Bucket: 'bucketName',
               Key: 'filename.ext',
               ETag: '"bf2acbedf84207d696c8da7dbb205b9f-5"' }
               */
              upload.on('uploaded', function (details) {
                  console.log(details);
              });
  
              // Pipe the incoming filestream through compression, and up to S3.
              read.pipe(compress).pipe(upload);
  
          })
  
      }
  </code></pre>
  
  <p>My config file is setup like so:</p>
  
  <pre><code>{
   "accessKeyId": "key",
   "secretAccessKey":"secret",
   "region": "us-east-1e"
  }
  </code></pre>
  
  <p>The code returns the following error: </p>
  
  <pre><code>    Failed to create a multipart upload on S3 : 
          {
              "message":"Missing credentials in config",
              "code":"CredentialsError",
              "time":"2015-07-28T22:59:10.763Z",
              "originalError":
                  {
                      "message":"Could not load credentials from any providers",
                      "code":"CredentialsError",
                      "time":"2015-07-28T22:59:10.763Z",
                      "originalError":
                          {
                              "message": "Connection timed out after 1000ms",
                              "code":"TimeoutError",
                              "time":"2015-07-28T22:59:10.762Z"
                          }
                  }
          }
  </code></pre>
  
  <p>To solve this I tried hard-coding the credentials using</p>
  
  <pre><code>AWS.config.update
  </code></pre>
  
  <p>Which doesn't seem to work as well. </p>
  
  <p>What could the reason be for the error? </p>
  
  <p>Thanks all!</p>