title: Amazon S3 upload file with java
body: <p>I'm trying to upload a file to amazon s3 and im getting 403 error, tried to follow an example provoded by amazon <a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjSingleOpJava.html" rel="nofollow noreferrer">example</a> here is my code:</p>
  
  <pre><code>public boolean uploadFile() {
      BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(id, secret);
      try {
          AmazonS3 client = AmazonS3ClientBuilder.standard()
                  .withRegion(Regions.US_EAST_2)
                  .withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials))
                  .build();
          client.putObject(new PutObjectRequest(bucketName, uploadFileName, this.file));
          return true;
      } catch (AmazonServiceException ase) {
          System.out.println("Caught an AmazonServiceException, which " +
                  "means your request made it " +
                  "to Amazon S3, but was rejected with an error response" +
                  " for some reason.");
          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());
          return false;
      } catch (AmazonClientException ace) {
          System.out.println("Caught an AmazonClientException, which " +
                  "means the client encountered " +
                  "an internal error while trying to " +
                  "communicate with S3, " +
                  "such as not being able to access the network.");
          System.out.println("Error Message: " + ace.getMessage());
          return false;
      }
  </code></pre>
  
  <p>What I was given by my client is the bucket, the id and the secret. If anyone could point out what i'm doing wrong and point me to some example I could look into. I'm new to amazon aws.</p>