Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LouisAmon/79c92a732dd464e43ac0d54849b514e1 to your computer and use it in GitHub Desktop.
Save LouisAmon/79c92a732dd464e43ac0d54849b514e1 to your computer and use it in GitHub Desktop.
Show AWS s3 download_file Progress using tqdm
#python3
def hook(t):
def inner(bytes_amount):
t.update(bytes_amount)
return inner
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, unit='B', unit_scale=True, desc=FILE_NAME) as t:
rootfs.download_file(path, Callback=hook(t))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment