Created
November 21, 2020 04:44
-
-
Save sambshapiro/5bbd0340c2366871dad0fb45dbd6183f to your computer and use it in GitHub Desktop.
Upload large file to Google Drive as Resumable Upload using Google Drive API
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
from googleapiclient.discovery import build | |
from googleapiclient.http import MediaFileUpload | |
media = MediaFileUpload(filename, mimetype='video/MP2T', resumable=True) # change mimetype to appropriate mimetype | |
google_drive_request = drive.files().create(media_body=media) | |
google_drive_response = None | |
while google_drive_response is None: | |
status, response = google_drive_request.next_chunk() | |
if status: | |
print("Uploaded %d%%." % int(status.progress() * 100)) | |
print("Google Drive Upload Complete!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment