Download Anything to Google Drive using Google colab

When we download/upload something from a cloud server, it gives more transfer rate as compared to a normal server. We can use Google Drive for storage as well as fast speed download. The problem is how to upload something to G-Drive direct from Internet. So, Here we will see a solution to upload anything to Google drive directly from Internet.

All we need is google account and a few lines of code.

Google Colab

Google Colab is a free cloud service with GPU support. It is like Jupyter Notebook and very simple to use. In this tutorial, we will be using Google Colab to download anything to our google drive.

Step #1 : Sign in to Google Colab and Create a new Python3 notebook.

Step #2 : Importing google drive to colab

To import google drive, write this code in code section of colab and run it by Ctrl+Enter .



from google.colab import drive

drive.mount( '/content/gdrive' )

On running code, one blue link and a text box will appear we need to provide a permission text. So click the link and a new tab will open where you will be asked for permission to access google drive. After providing permissions a text will be displayed that we need to Copy and paste on colabs text box.


Paste text in box and press enter. That all to import gdrive. We can see google drive on Left side Panel.

Step #3 : Download something to Google Drive

To download something all we need is URL to downloadable file.

import requests
file_url = “

r = requests.get(file_url, stream = True)

with open("/content/gdrive/My Drive/python.pdf", “wb”) as file:
for block in r.iter_content(chunk_size = 1024):
if block:

Run this code to download the files in gdrive (Change the file_url with your file’s url ).

We can see on the left side panel that pdf file is downloaded.

Conclusion :

We can use google colab to download any file on google drive.

As you can see a folder parrot (parrot OS of 3.7 GB ), downloaded to gdrive using Colab.

Material source:Geeks for Geeks


is there any way to download lynda courses to gdrive with this method?

Hi, @jmpinto
Thank you for this detailed explanation.
I want to confirm one thing.
So, if we have a Gdrive link from other users, we can use this to transfer files from their Gdrive to our Gdrive with the use of Google server’s bandwidth and not ours?
Also does this work on Shared Drives/Team Drives?

Please check this, how so i solve it ?

1 Like

u have to change double quotes

1 Like

Hi @Makaroni_Makaroni ac
I never tryed

Hi @rawn7702
I already use it with Shared Drives?Team Drives and worked
But I never tryed with Gdrive Links

you don’t need to use this to copy from gdrive to gdrive, share it and use copy to drive, it will copy it for you.

edit: if for some reason you still wanna use this, it will not consume your bandwidth but google colabs data.

1 Like

So basically take any download link and use this to transfer it to your gdrive or shared drive right?

Yes thats it

1 Like

Does any one know how I can zip folders in gdrive for easy download

Thank you so much sir :heart:

Any YouTube video link for colab download anything in Google drive.
Because I didn’t understand above steps and commands.
So please help for steps by steps method.

@ jmpinto, cool tutorial buddy.

I’m not able to use it because google keeps asking me to sign in (I get stuck in a loop) when trying to create a python notebook on Google Collab.

Bu I can see how this is really handy to download stuff directly to your G Drive, instead of downloading to your PC and then having to upload it to the Drive.

I can’t get python 3 notebook
Only New notebook shows
What to do know.

Just my 2 cents ~~
to unzip something which you have downloaded in the drive, here is the code:-
!unzip ‘path of the zip file’ -d ‘path where the file is to be unzipped’
!unzip ‘/gdrive/My Drive/’ -d ‘/gdrive/My Drive/Destination/’


Thanks :heart_eyes:

can someone revise this code pleas the code doesn’t work or any other method

This is awesome way :slight_smile: to save data on gdrive if someone has a lot of data to save but one must have GB’s of space on google drive to store all that data. As Google only gives 15gb so just to save 15gb, I prefer to save on my local hdd.

I think all these users so far who posted, they must be having so many GB’s of space in their gdrive that;s why they all are so fired up.

I wish I’d also get GB’s in gdrive!
Anyways thanks for sharing , I appreciate that :slight_smile:

Hey @jmpinto What the wrong with me can you suggest please. I want to download this file into my google drive but i can’t please help me and write the code for me please please please…

My code was:

import requests

file_url = “”

r = requests.get(file_url, stream = True)

with open("/content/drive/My Drive/Colab Notebooks", “wb”) as file:

for block in r.iter_content(chunk_size = 1024):

if block:


Friendly Websites