Forked from wy193777/s3_download_file_progress_bar.py
Created
October 19, 2018 10:57
-
-
Save LouisAmon/79c92a732dd464e43ac0d54849b514e1 to your computer and use it in GitHub Desktop.
Show AWS s3 download_file Progress using tqdm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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