Bucket / Action / upload_file

upload_file#

S3.Bucket.upload_file(Filename, Key, ExtraArgs=None, Callback=None, Config=None)#

Upload a file to an S3 object.

Usage:

import boto3
s3 = boto3.resource('s3')
s3.Bucket('mybucket').upload_file('/tmp/hello.txt', 'hello.txt')

Similar behavior as S3Transfer’s upload_file() method, except that parameters are capitalized. Detailed examples can be found at S3Transfer’s Usage.

Parameters:
  • Filename (str) – The path to the file to upload.

  • 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 transfer.