How do you upload and download S3 objects efficiently?
IntermediateConceptboto3 & AWS automation
Answer
Use the managed transfer methods, which do multipart uploads and parallel parts automatically:
from boto3.s3.transfer import TransferConfig
cfg = TransferConfig(multipart_threshold=64 * 2**20, max_concurrency=10)
s3.upload_file("backup.tar.gz", "acme-backups", "db/2026-11-09.tar.gz", Config=cfg,
ExtraArgs={"ServerSideEncryption": "aws:kms", "StorageClass": "STANDARD_IA"})
s3.download_file("acme-backups", key, "/tmp/restore.tar.gz")
put_object is a single request limited to 5 GB and has no parallelism. Use list_objects_v2 paginators, not list_objects.
More on boto3 & AWS automation
What is the difference between a boto3 Session, client and resource?BeginnerHow does boto3 find credentials?BeginnerHow does boto3 decide the region, and what is the gotcha with `AWS_REGION`?AdvancedWhy do you need paginators, and how do you use them?BeginnerWhat is JMESPath `search()` on paginators?AdvancedHow do you handle errors from boto3?Beginner