The easiest way to download files from the internet directly to Google Drive

未分類

When you have to store a large file on Google Drive, you don’t want to download the file to your local computer for uploading to Google Drive. You can download a file directly to Google Drive via Google Colab. I’m going to show how to do it.

First, go to Google Colab and create a new .ipynb notebook. Copy and paste the following code to a cell.

from google.colab import drive
drive.mount('/content/gdrive')

Click the URL next to Go to this URL in a browser: and copy your authorization code. Go back to the notebook page and paste the authorization code. Now you have mounted your Google Drive storage in Google Colab, so you can download a file directly to Google Drive using wget.

In the example below, I will download the laboro_tomato.zip file and copy the file to Google Drive.

!wget http://assets.laboro.ai/laborotomato/laboro_tomato.zip
!cp laboro_tomato.zip gdrive/My\ Drive/laboro_tomato.zip

You can check if your file is stored in your Google Drive like this.

ls gdrive/My\ Drive/

Comments

Copied title and URL