title: AWS S3 Requester Pays Does not work with TransferManager
body: <p>I am trying to use <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/TransferManager.html" rel="nofollow noreferrer">TransferManager</a> class in my java program to download a file from a <a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/RequesterPaysBuckets.html" rel="nofollow noreferrer">Requester Pays Buckets</a>.
  I am getting "Status Code: 403" exception from amazon AWS.
  I wrote a simple program to test this feature and compare it single connection way of downloading a file. Here is my code:</p>
  
  <pre><code>import java.io.*;
  import com.amazonaws.auth.*;
  import com.amazonaws.services.s3.*;
  import com.amazonaws.services.s3.model.*;
  import com.amazonaws.services.s3.transfer.*;
  import com.amazonaws.util.IOUtils;
  public class RequesterPaysTest {
      final static AWSCredentials awsCredentials = new BasicAWSCredentials(MY IAMAccessKey,MY IAMSecretKey);
      final static String bucketName = "7268982505fe.mixnode.com";
      final static String fileName = "5379-7268982505fe-0-1496081968663.warc.gz";
      final static AWSCredentialsProvider awsCredentialsProvider =  new AWSStaticCredentialsProvider(awsCredentials);
      final static AmazonS3 s3client = AmazonS3ClientBuilder.standard().withCredentials(awsCredentialsProvider).withRegion(MY bucketRegion).build();
      final static GetObjectRequest getRequest = new GetObjectRequest(bucketName, fileName, true);
  
      static void testSimpleRequesterPays() {
          try {
          S3Object object = s3client.getObject(getRequest);
          InputStream objectData = object.getObjectContent();
          FileOutputStream out = new FileOutputStream (new File(fileName));
          IOUtils.copy(objectData, out);
          out.close();
          System.out.println(" Simple RequesterPays successful");
          } catch (Exception e) {
          System.out.println(" Simple RequesterPays unsuccessful: " + e.getMessage());
          }
      }
      static void testTransferManagerRequesterPays() {
          try {
              TransferManager tx = TransferManagerBuilder.standard().withS3Client(s3client).build();
              Download download = tx.download(getRequest, new File(fileName));
              while (download.isDone() == false)
                  Thread.sleep(10);
              System.out.println(" TransferManager RequesterPays successful");
          } catch (Exception e) {
          System.out.println(" TransferManager RequesterPays unsuccessful: " + e.getMessage());
          }
      }
  public static void main(String[] args) throws IOException {
      testSimpleRequesterPays();
      testTransferManagerRequesterPays();
  }
  }
  </code></pre>
  
  <p>And here is the output:</p>
  
  <pre><code>Simple RequesterPays successful
   TransferManager RequesterPays unsuccessful: Forbidden (Service: Amazon S3; Status Code: 403; Error Code: 403 Forbidden; Request ID: 77D5EBF5EE195A7A)
  </code></pre>
  
  <p>As you can see, the same file can be downloaded using simple method but not with TransferManager. I tried to create my own bucket and played around with permissions but it did not work.
  I was wondering if I miss anything in my code? Or whether AWS s3 does not have support for using TransferManager on a requester pays bucket?</p>