AWS S3 File Uploads Timeout During Browser Uploads w/ Signed URLs
<p>I've been trying to get this to work for 2 days now. I am able to get a signed URL from my Node server with the credentials for my bucket and the file information, but when I try to upload the file with the signed URL, I get timed out. Here is some code: </p>

<pre><code>    var AWS_ACCESS_KEY = process.env.AWS_ACCESS_KEY;
    var AWS_SECRET_KEY = process.env.AWS_SECRET_KEY ;
    var S3_BUCKET = process.env.S3_BUCKET;

    exports.getS3Credentials = function(req, res) {
      aws.config.update({accessKeyId: AWS_ACCESS_KEY, secretAccessKey: AWS_SECRET_KEY});
      var s3 = new aws.S3();

      // The date is to help avoid overwriting
      var s3Key = Date.now() + req.query.file_name;

      var s3_params = {
        Bucket: S3_BUCKET,
        Key: s3Key,
        Expires: 60,
        ContentType: req.query.file_type,
        ACL: 'public-read'
      };
      s3.getSignedUrl('putObject', s3_params, function(err, data) {
        if (err) {
          console.log(err);
        } else {
          var return_data = {
            signed_request: data,
            url: 'https://'+S3_BUCKET+'.s3.amazonaws.com/'+s3Key
          };
          res.json(return_data);
        }
      });
    };
</code></pre>

<p>I call the above method via GET request from Angular:</p>

<pre><code>var fd = new FormData();
    $scope.getS3Credentials = function(item){
          $http.get('/api/programs/gets3credentials?file_name=' + item.name + '&amp;file_type=' + item.type).then(function(res) {
            $scope.program.profileImageURL = res.data.url;
            $scope.credentialsUrl = res.data.signed_request;
          });
          $scope.imageFile = item;
          fd.append('file', item);
        };
</code></pre>

<p>Everything seems to go well till here. I then use a PUT request to upload:</p>

<pre><code>$http.put($scope.credentialsUrl, fd, {
        transformRequest:angular.identity,
        headers:{'Content-Type':undefined}
      }).then(function(d) {
        console.log(d);
        // Redirect after save
        program.$save(function (response) {
          // Clear form fields
          clearFields();
          $location.path('programs/' + response._id);
        }, function (errorResponse) {
          $scope.error = errorResponse.data.message;
        });
      }, function(err){
        console.log(err)
      });
</code></pre>

<p>After this, I get no errors till it times out. I've cycled through several ways to try and get it to upload, but all come back with the same result. Could permissions be the cause of this?</p>