Created
August 18, 2018 12:49
-
-
Save fuatbeser/378d2f929159578efd259c3fb4c289b6 to your computer and use it in GitHub Desktop.
Send large files from Google Colab to Google Drive.
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
# 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