download_fileobj

S3.Client.download_fileobj(Bucket, Key, Fileobj, ExtraArgs=None, Callback=None, Config=None)

Download an object from S3 to a file-like object.

The file-like object must be in binary mode.

This is a managed transfer which will perform a multipart download in multiple threads if necessary.

Usage:

import boto3
s3 = boto3.client('s3')

with open('filename', 'wb') as data:
    s3.download_fileobj('mybucket', 'mykey', data)
Parameters
  • Bucket (str) -- The name of the bucket to download from.
  • Key (str) -- The name of the key to download from.
  • Fileobj (a file-like object) -- A file-like object to download into. At a minimum, it must implement the write method and must accept bytes.
  • ExtraArgs (dict) -- Extra arguments that may be passed to the client operation. For allowed download arguments see boto3.s3.transfer.S3Transfer.ALLOWED_DOWNLOAD_ARGS.
  • Callback (function) -- A method which takes a number of bytes transferred to be periodically called during the download.
  • Config (boto3.s3.transfer.TransferConfig) -- The transfer configuration to be used when performing the download.