title: Download file to stream instead of File
body: <p>I'm implementing an helper class to handle transfers from and to an AWS S3 storage from my web application.</p>
  
  <p>In a first version of my class I was using directly a <code>AmazonS3Client</code> to handle upload and download, but now I discovered <code>TransferManager</code> and I'd like to refactor my code to use this.</p>
  
  <p>The problem is that in my download method I return the stored file in form of <code>byte[]</code>. TransferManager instead has only methods that use <code>File</code> as download destination (for example <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/TransferManager.html#download(com.amazonaws.services.s3.model.GetObjectRequest,%20java.io.File)" rel="nofollow"><code>download(GetObjectRequest getObjectRequest, File file)</code></a>).</p>
  
  <p>My previous code was like this:</p>
  
  <pre><code>GetObjectRequest getObjectRequest = new GetObjectRequest(bucket, key);
  S3Object s3Object = amazonS3Client.getObject(getObjectRequest);
  S3ObjectInputStream objectInputStream = s3Object.getObjectContent();
  byte[] bytes = IOUtils.toByteArray(objectInputStream);
  </code></pre>
  
  <p>Is there a way to use <code>TransferManager</code> the same way or should I simply continue using an <code>AmazonS3Client</code> instance?</p>