Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add progress bar when downloading large files. #4269

Closed
shahanaz873 opened this issue Jul 9, 2020 · 2 comments
Closed

How to add progress bar when downloading large files. #4269

shahanaz873 opened this issue Jul 9, 2020 · 2 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@shahanaz873
Copy link

I am downloading a large file (5GB) from the bucket. How to show progress bar when blob.download_to_filename(destination_file_name) starts and ends

@busunkim96
Copy link
Contributor

Hi, it looks like this isn't currently a feature of the library. See googleapis/python-storage#27.

Someone did post a workaround which may work for you.

@busunkim96 busunkim96 added the type: question Request for information or clarification. Not an issue. label Jul 9, 2020
@shahanaz873
Copy link
Author

shahanaz873 commented Jul 13, 2020

@busunkim96 I followed the above workaround but how to read the source file from the bucket to download.


blob_name = config_data['name']
blob = bucket.get_blob(blob_name)
size = blob.size
content_type = blob.content_type
try:
     with open(blob, "wb") as in_file:
     total_bytes = os.fstat(in_file.fileno()).st_size
     with tqdm.wrapattr(blob, "read", total=size, miniters=1, desc="Downloading") as destination_file_name:
     blob.download_to_filename(destination_file_name, content_type=content_type, size=size)
     return blob
except Exception as e:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants