Skip to content

Instantly share code, notes, and snippets.

@sambshapiro
Created November 21, 2020 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sambshapiro/5bbd0340c2366871dad0fb45dbd6183f to your computer and use it in GitHub Desktop.
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
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