I want to download the file that is viewable at this address to a linux remote:
https://drive.google.com/file/d/0Bz7KyqmuGsilT0J5dmRCM0ROVHc/view?usp=sharing
I'm hoping I can do this with wget
.
I tried
wget https://drive.google.com/file/d/0Bz7KyqmuGsilT0J5dmRCM0ROVHc/vgg16_weights.h5
and the response was a 404.
Is it possible to wget
a google drive file? If so, what is the path to provide? If not, are there any alternatives (bash or other) so I can avoid downloading the file to my local and transferring it to the remote?
Insert your file ID into this URL (https://drive.google.com/uc?export=download&id=
), then surround the URL with quotes so that Bash doesn't misinterpret the &
, like so:
wget "https://drive.google.com/uc?export=download&id=0Bz7KyqmuGsilT0J5dmRCM0ROVHc"
Reference here.
When downloading big files, Google Drive adds a security warning that breaks the script above. In that case, you can download the file using:
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILEID" -O FILENAME && rm -rf /tmp/cookies.txt
(Script taken from here)
The shortest way I have found for downloading big files:
git clone https://github.com/chentinghao/download_google_drive.git
cd download_google_drive/
python download_gdrive.py FILE_ID DESTINATION_PATH
Just view access, FILE_ID and DESTINATION_PATH (including file name) are required. It's working now as of November/12/2019 and has been for more than a year.
Another solution is googleapiclient. It enables you to automate downloading/uploading private files having their ids.
Note: Also make sure that file is publicly shared not with a group or within an organization
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With