Skip to content

Instantly share code, notes, and snippets.

@minesh1291
Forked from fuatbeser/colab2drive.py
Created June 28, 2020 19:44
Show Gist options
  • Select an option

  • Save minesh1291/363caebab5b16f2d281e3c8aa2d9dd26 to your computer and use it in GitHub Desktop.

Select an option

Save minesh1291/363caebab5b16f2d281e3c8aa2d9dd26 to your computer and use it in GitHub Desktop.
Send large files from Google Colab to Google Drive.
# Which file to send?
file_name = "REPO.tar"
from googleapiclient.http import MediaFileUpload
from googleapiclient.discovery import build
auth.authenticate_user()
drive_service = build('drive', 'v3')
def save_file_to_drive(name, path):
file_metadata = {'name': name, 'mimeType': 'application/octet-stream'}
media = MediaFileUpload(path, mimetype='application/octet-stream', resumable=True)
created = drive_service.files().create(body=file_metadata, media_body=media, fields='id').execute()
return created
save_file_to_drive(file_name, file_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment