wget/curl large file from google drive
April 2021
You can use the gdown.
Install it with the following command:
pip install gdown
After that, you can download any file from Google Drive by running this command:
gdown https://drive.google.com/uc?id=file_id
The file_id
should look something like 0Bz8a_Dbh9QhbNU3SGlFaDg
, replace this value with the file_id
of your file and it will work.
You can get it by right clicking on the file and then Get shareable link.Only work on open access files (Anyone who has a link can View).Does not work for directories.Tested on Google Colab.Works best on file download.Use tar/zip to make it a single file.
Example: to download the readme file from this directory
gdown https://drive.google.com/uc?id=0B7EVK8r0v71pOXBhSUdJWU1MYUk
I wrote a Python snippet that downloads a file from Google Drive, given a shareable link. It works, as of August 2017.
The snipped does not use gdrive, nor the Google Drive API. It uses the requests module.
When downloading large files from Google Drive, a single GET request is not sufficient. A second one is needed, and this one has an extra URL parameter called confirm, whose value should equal the value of a certain cookie.
import requestsdef download_file_from_google_drive(id, destination): def get_confirm_token(response): for key, value in response.cookies.items(): if key.startswith('download_warning'): return value return None def save_response_content(response, destination): CHUNK_SIZE = 32768 with open(destination, "wb") as f: for chunk in response.iter_content(CHUNK_SIZE): if chunk: # filter out keep-alive new chunks f.write(chunk) URL = "https://docs.google.com/uc?export=download" session = requests.Session() response = session.get(URL, params = { 'id' : id }, stream = True) token = get_confirm_token(response) if token: params = { 'id' : id, 'confirm' : token } response = session.get(URL, params = params, stream = True) save_response_content(response, destination) if __name__ == "__main__": import sys if len(sys.argv) is not 3: print("Usage: python google_drive.py drive_file_id destination_file_path") else: # TAKE ID FROM SHAREABLE LINK file_id = sys.argv[1] # DESTINATION FILE ON YOUR DISK destination = sys.argv[2] download_file_from_google_drive(file_id, destination)
WARNING: This functionality is deprecated. See warning below in comments.
Have a look at this question: Direct download from Google Drive using Google Drive API
Basically you have to create a public directory and access your files by relative reference with something like
wget https://googledrive.com/host/LARGEPUBLICFOLDERID/index4phlat.tar.gz
Alternatively, you can use this script: https://github.com/circulosmeos/gdown.pl