AWS Java SDK Error Message: The authorization header is malformed; the authorization header requires three components
<p>I am getting following error while trying to put a file in AWS bucket</p>

<p>Error Message:    The authorization header is malformed; the authorization header requires three components: Credential, SignedHeaders, and Signature. (Service: Amazon S3; Status Code: 400; Error Code: AuthorizationHeaderMalformed; Request ID: abc)
HTTP Status Code: 400
AWS Error Code:   AuthorizationHeaderMalformed
Error Type:       Client
Request ID:       abc
I am using following code to do this task. Any idea what I am  doing wrong. </p>

<pre><code>AWSCredentials awsCredentials = new BasicAWSCredentials("key",", "secret");
AmazonS3 s3Client = new AmazonS3Client(awsCredentials);
        s3Client.setRegion(com.amazonaws.regions.Region.getRegion(Regions.US_WEST_2));

String key = "test";
try {
     s3Client.putObject(new PutObjectRequest(bucketName, key, file);

      } catch (AmazonServiceException ase) {

         System.out.println("Error Message:    " + ase.getMessage());
         System.out.println("HTTP Status Code: " + ase.getStatusCode());
         System.out.println("AWS Error Code:   " + ase.getErrorCode());
         System.out.println("Error Type:       " + ase.getErrorType());
         System.out.println("Request ID:       " + ase.getRequestId());
     } catch (AmazonClientException ace) {
         System.out.println("Caught an AmazonClientException, which means the client encountered "
                 + "a serious internal problem while trying to communicate with S3, "
                 + "such as not being able to access the network.");
         System.out.println("Error Message: " + ace.getMessage());
     }
</code></pre>