Skip to content

MediaIoBaseDownload Cannot Handle Resuming Partial Download #2309

New issue

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

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

Already on GitHub? # to your account

Closed
coanghel opened this issue Jan 4, 2024 · 2 comments · May be fixed by #2310
Closed

MediaIoBaseDownload Cannot Handle Resuming Partial Download #2309

coanghel opened this issue Jan 4, 2024 · 2 comments · May be fixed by #2310
Assignees
Labels
status: investigating The issue is under investigation, which is determined to be non-trivial. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@coanghel
Copy link

coanghel commented Jan 4, 2024

Title summarizes the issue. As is, you cannot resume a partial download by using MediaIoBaseDownload()

Steps to reproduce

  1. Start a download with MediaIoBaseDownload() and interrupt it
  2. Create a new request and pass the relevant Range header to resume the download
  3. Starting a new download with the above request will always start the download from byte 0 due to the constructor for MediaIoBaseDownload() setting progress to 0, and the range header being overwritten in next_chunk()

Code example

try:
        headers = {'Range': f'bytes={partial_size}-'} if partial_size > 0 and partial_size < total_size else {}
        request = thread_service.files().get_media(fileId=file_id)
        request.headers.update(headers)

        with open(local_file_path, 'ab' if partial_size > 0 else 'wb') as f:
            downloader = MediaIoBaseDownload(f, request, chunksize=1024*1024*15)
            done = False
            while not done:
                _, done = downloader.next_chunk()
    except HttpError as error:
        print(f"An error occurred while downloading {file_name}: {error}")
        return False
@parthea parthea added status: investigating The issue is under investigation, which is determined to be non-trivial. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Jan 8, 2024
@ohmayr
Copy link
Contributor

ohmayr commented Jan 9, 2024

This appears to be a feature request (not a bug) which we don't support in this library, see the ReadMe.

To request a new feature, you can follow this link: Submit feature request

@ohmayr ohmayr closed this as completed Jan 9, 2024
@coanghel
Copy link
Author

coanghel commented Jan 9, 2024

Hi @ohmayr, JP on the issue tracker routed me back here... can I get some feedback on the right way to submit this feature request?

Also, is this truly a feature request if intended functionality (resuming downloads) is missing and there is no API available, as far as I can tell, in google-cloud-python to download files from drive?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
status: investigating The issue is under investigation, which is determined to be non-trivial. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants