参考:
<40M 文件 且是 公开分享:
用wget:
https://lccurious.github.io/2021/05/15/Download-from-Google-Drive/
<10G 且是 公开分享:
curl:
https://github.com/JinhangZhu/yolov3/blob/custom/data/get_coco2014.sh
# cd scratch place
cd scratch/
# Download zip dataset from Google Drive
filename='OfficeHomeDataset_10072016.zip'
fileid='0B81rNlvomiwed0V1YUxQdC1uOTg'
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o ${filename}
rm ./cookie
# Unzip
#unzip -q ${filename}
#rm ${filename}
# cd out
cd
>10G 或者是 私密分享:
上面的方法会出现找不到文件的情况,用Google的官方API和认证token可以解决:
https://www.pianshen.com/article/8221279796/
或者查看英文原版问题答案:
以下答案来自:https://www.quora.com/How-do-I-download-a-very-large-file-from-Google-Drive
Get the file ID:
Go to your Google Drive in your browser.
Right-click (or control-click) the file you want to download and click “Get shareable link”. The link looks like this: https://drive.google.com/open?id=XXXXX. Make note of the file ID “XXXXX”; you will be needing it below.
Get an OAuth token:
Go to OAuth 2.0 Playground
In the “Select the Scope” box, scroll down, expand “Drive API v3”, and select https://www.googleapis.com/auth/drive.readonly
Click “Authorize APIs” and then “Exchange authorization code for tokens”. Copy the “Access token”; you will be needing it below.
Download the file from the command line:
curl -H “Authorization: Bearer YYYYY” https://www.googleapis.com/drive/v3/files/XXXXX?alt=media -o ZZZZZ