Select your cookie preferences

We use cookies and similar tools to enhance your experience, provide our services, deliver relevant advertising, and make improvements. Approved third parties also use these tools to help us deliver advertising and provide certain site features.

upload_fileobj

upload_fileobj(Fileobj, Bucket, Key, ExtraArgs=None, Callback=None, Config=None)

Upload a file-like object to S3.

The file-like object must be in binary mode.

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

Usage:

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

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