question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug in http.MediaIoBaseDownload

See original GitHub issue

Problem is here. If content-range is not found in response. This will leads to infinite loop because self._total_size will always be None and self._progress == self._total_size will always results in False hence self._done will never be True. Shouldn’t it raise an exception if content-range header is not found?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:22 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
musalbascommented, Jul 9, 2015

This is still an issue, and a serious one because it makes it impossible to download objects from Google Cloud Storage buckets using MediaIoBaseDownload.

Here’s another way of getting objects (this does it in one go and stores it in memory, so may not be suitable for large files):

request = client.objects().get_media(bucket="blab", object="blab")
response = request.execute()
print response
4reactions
markz0rcommented, Aug 12, 2016

For anyone looking for a work around:

def downloadFile(file_name, file_id, mimeType, service):
    request = service.files().get_media(fileId=file_id)
    if "application/vnd.google-apps" in mimeType:
        if "document" in mimeType:
            request = service.files().export_media(fileId=file_id, mimeType='application/vnd.openxmlformats-officedocument.wordprocessingml.document')
            file_name = file_name + ".docx"
        else:
            request = service.files().export_media(fileId=file_id, mimeType='application/pdf')
            file_name = file_name + ".pdf"
    print("Downloading -- " + file_name)
    response = request.execute()
    with open(os.path.join(OUTPUT_DIR, file_name), "wb") as wer:
        wer.write(response)
Read more comments on GitHub >

github_iconTop Results From Across the Web

google-api-python-client bug with media downloading
The google-api-python-client library has a bug where downloads will never be ... mimeType=mime_type) downloader = MediaIoBaseDownload(fh, ...
Read more >
googleapiclient.http.MediaIoBaseDownload ... - Program Talk
MediaIoBaseDownload. Learn how to use python api googleapiclient.http.MediaIoBaseDownload. ... MediaIoBaseDownload taken from open source projects.
Read more >
googleapiclient.http.MediaIoBaseDownload - Google APIs
"Download media resources. Note that the Python file object is compatible with io.Base and can be used with this class also. Example: request...
Read more >
Python Code Samples | YouTube Analytics and Reporting APIs
If you specify a report URL, the script downloads that report. ... from googleapiclient.http import MediaIoBaseDownload
Read more >
python invalid start byte - You.com | The search engine you control.
... from google.auth.transport.requests import Request from googleapiclient.http import MediaIoBaseDownload, ... This is a known bug in Pandas.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found