I often find myself in the situation where I have large files on various online services like Dropbox or various VPSs that I want to backup or otherwise store in Google Drive.
It seems stupid to have to download them to my desktop and then re-upload them. Good news! There’s a way to download straight into Google Drive, using Google Colaboratory.
I stole this trick from somewhere and I use it all the time to upload files directly into Google Drive.
- Create a new Colab notebook
- Add a new cell with the following contents:
from google.colab import drive
- Run the code. It will prompt you to authenticate this new ‘application’ against Google Drive so it can access your files.
- Create a new cell with the following contents:
!wget -P /content/drive/My\ Drive https://example.com/test.zip
- Run the code. It will download the file, using wget, directly from the requested URL, showing you the live progress.
- For bonus points, you can also check the hash of the file once it has downloaded to make sure it has the contents you’re expecting (note here that you can also reference ‘My Drive’ like ‘MyDrive’?):