title: Amazon S3 upload image - using angular js directly from browser
body: <p>I am trying to upload images from my browser to Amazon S3 directly, using angular js.</p>
  
  <p>Below is my code. </p>
  
  <pre><code>function _upload($files) {
                  $scope.file = $files[0];
                  $scope.creds = {
                      access_key: '***',
                      secret_key: '***',
                      bucket: 'sabari-test'
                  };
  
                  var bucket = new AWS.S3({
                      params: {
                          Bucket: $scope.creds.bucket
                      }
                  });
                  AWS.config.accessKeyId = $scope.creds.access_key;
                  AWS.config.secretAccessKey = $scope.creds.secret_key;
                  AWS.config.region = 'us-west-2';
  
                  // AWS.
  
                  if ($scope.file) {
                      // Perform File Size Check First
                      var fileSize = Math.round(parseInt($scope.file.size));
                      if (fileSize &gt; $scope.sizeLimit) {
                          console.log('Sorry, your attachment is too big.');
                          return false;
                      }
                      // Prepend Unique String To Prevent Overwrites
                      var uniqueFileName = 'hai' + '-' + $scope.file.name;
  
                      var params = {
                          Key: uniqueFileName,
                          ContentType: $scope.file.type,
                          Body: $scope.file,
                          ServerSideEncryption: 'AES256'
                      };
  
                      bucket.putObject(params, function(err, data) {
                          if (err) {
                              console.log(err.message);
                              return false;
                          } else {
                              // Upload Successfully Finished
                              console.log('File Uploaded Successfully');
                          }
                      })
                  } else {
                      // No File Selected
                      console.log('Please select a file to upload');
                  }
              }
  </code></pre>
  
  <p>I get the below error:</p>
  
  <p>"Missing credentials in config"</p>
  
  <p>Please let me know what is the missing credential?</p>
  
  <p>Thanks.</p>