Equivalent to get_contents_to_file in boto3 : <p>In boto3, is there an equivalent of <a href="http://boto.cloudhackers.com/en/latest/ref/s3.html#boto.s3.key.Key.get_contents_to_file" rel="noreferrer"><code>get_contents_to_file</code></a>, that copies the contents of an object to a file handle?</p>

<p>In boto, if I have an S3 object <code>key</code>, I can copy the contents to a temporary file with:</p>

<pre><code>from tempfile import TemporaryFile
key = code_that_gets_key()

with TemporaryFile() as tmp_file:
    key.get_contents_to_file(key, tmpfile)
</code></pre>

<p>I haven't found an equivalent in boto3. </p>

<p>I have been able to replace usage of <a href="http://boto.cloudhackers.com/en/latest/ref/s3.html#boto.s3.key.Key.get_contents_to_filename" rel="noreferrer"><code>get_contents_to_filename</code></a> with <a href="http://boto3.readthedocs.org/en/latest/reference/services/s3.html?highlight=download_file#S3.Object.download_file" rel="noreferrer"><code>download_file</code></a>. However, that covers the case where I provide the filename. In this case, I want to provide the file handle as the argument.</p>

<p>Currently, I can get the code to work in boto3 by iterating over the body as follows:</p>

<pre><code>with TemporaryFile() as tmp_file:
    body = key.get()['Body']
    for chunk in iter(lambda: body.read(4096), b''):
        filehandle.write(chunk)
</code></pre>

<p>Is there a better way to do this in boto3?</p>
