Skip to content

Instantly share code, notes, and snippets.

@LTeder
LTeder / s3_download_file_progress_bar.py
Last active March 2, 2024 16:45 — forked from wy193777/s3_download_file_progress_bar.py
AWS S3 download_fileobj tqdm progress callback
#python3
BUCKET_NAME = 'your_s3_bucket_name'
FILE_NAME = 'your_s3_file_name'
s3 = boto3.resource('s3')
path = "/tmp/{}".format(FILE_NAME)
file_object = s3.Object(BUCKET_NAME, FILE_NAME)
filesize = file_object.content_length
with tqdm(total=filesize, desc=f'source: s3://{s3_bucket}/{s3_object_key}',
bar_format="{percentage:.1f}%|{bar:25} | {rate_fmt} | {desc}",