# Download Anything to Google Drive using Google colab

**URL:** <https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228>\
**Category:** Tools & Scripts\
**Tags:** cloud-storage, tips-tricks\
**Created:** [March 13, 2020, 3:36pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228 "2020-03-13T15:36:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmpinto](https://onehack.st/user_avatar/onehack.st/jmpinto/32/26546_2.png) [@jmpinto](https://onehack.st/u/jmpinto)\
**Post date:** [March 13, 2020, 3:36pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/1 "2020-03-13T15:36:50Z")

</div>

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](https://colab.research.google.com/notebooks/welcome.ipynb)**

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.

 ![image](https://onehack.st/uploads/default/original/3X/0/7/07508c093b350d17093d37267dec6ce251eeba02.png)

 ![image](https://onehack.st/uploads/default/original/3X/4/2/4247e9f5e9ee46537026a8999410afa8387c9e2e.png)

**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` .

_filter\_none_

_brightness\_4_

`from` `google.colab ` `import` `drive `

`drive.mount(` `'/content/gdrive'` `) `

 ![image](https://onehack.st/uploads/default/original/3X/4/2/4247e9f5e9ee46537026a8999410afa8387c9e2e.png)

[![](https://media.geeksforgeeks.org/wp-content/uploads/20190224141038/colab3.png) ](https://media.geeksforgeeks.org/wp-content/uploads/20190224141038/colab3.png)

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.

 ![image](https://onehack.st/uploads/default/original/3X/7/1/71cc5590e0e5b2df6da036a741f71a83bdbcce37.png)

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

 ![image](https://onehack.st/uploads/default/original/3X/1/5/15599abe07d6787654acb579c6623e0161d8a064.png)

**Step #3 : Download something to Google Drive**

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

import requests  
file\_url = “[http://1.droppdf.com/files/5iHzx/automate-the-boring-stuff-with-python-2015-.pdf](http://1.droppdf.com/files/5iHzx/automate-the-boring-stuff-with-python-2015-.pdf)”

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:  
file.write(block)

Run this code to download the files in gdrive (Change the _file\_url_ with your **file’s url** ).

 ![image](https://onehack.st/uploads/default/original/3X/0/e/0e0ec8741b22fbf17f7b75dc509b6024d7924bd1.png)

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

---

<div class="post-metadata">

**Author:** ![Makaroni\_Makaroni](https://onehack.st/user_avatar/onehack.st/makaroni_makaroni/32/24237_2.png) [@Makaroni\_Makaroni](https://onehack.st/u/Makaroni_Makaroni)\
**Post date:** [March 13, 2020, 4:34pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/2 "2020-03-13T16:34:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rawn7702](https://onehack.st/user_avatar/onehack.st/rawn7702/32/104678_2.png) [@rawn7702](https://onehack.st/u/rawn7702)\
**Post date:** [March 13, 2020, 4:40pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/4 "2020-03-13T16:40:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Digital\_Sheba](https://onehack.st/user_avatar/onehack.st/digital_sheba/32/22935_2.png) [@Digital\_Sheba](https://onehack.st/u/Digital_Sheba)\
**Post date:** [March 13, 2020, 5:18pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/5 "2020-03-13T17:18:55Z")

</div>

![IMG_20200313_231757](https://onehack.st/uploads/default/original/3X/5/d/5d3246716338ced6c200ea4253d82e493e753139.png)  
Please check this, how so i solve it ?

---

<div class="post-metadata">

**Author:** ![Keke\_Bija](https://onehack.st/user_avatar/onehack.st/keke_bija/32/37186_2.png) [@Keke\_Bija](https://onehack.st/u/Keke_Bija)\
**Post date:** [March 13, 2020, 6:11pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/6 "2020-03-13T18:11:37Z")

</div>

u have to change double quotes

---

<div class="post-metadata">

**Author:** ![jmpinto](https://onehack.st/user_avatar/onehack.st/jmpinto/32/26546_2.png) [@jmpinto](https://onehack.st/u/jmpinto)\
**Post date:** [March 13, 2020, 7:33pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/7 "2020-03-13T19:33:40Z")

</div>

Hi @Makaroni_Makaroni ac  
I never tryed  
Sorry

---

<div class="post-metadata">

**Author:** ![jmpinto](https://onehack.st/user_avatar/onehack.st/jmpinto/32/26546_2.png) [@jmpinto](https://onehack.st/u/jmpinto)\
**Post date:** [March 13, 2020, 7:36pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/8 "2020-03-13T19:36:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Cain](https://onehack.st/user_avatar/onehack.st/cain/32/40108_2.png) [@Cain](https://onehack.st/u/Cain)\
**Post date:** [March 13, 2020, 9:55pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/9 "2020-03-13T21:55:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rawn7702](https://onehack.st/user_avatar/onehack.st/rawn7702/32/104678_2.png) [@rawn7702](https://onehack.st/u/rawn7702)\
**Post date:** [March 14, 2020, 6:50am UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/10 "2020-03-14T06:50:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jmpinto](https://onehack.st/user_avatar/onehack.st/jmpinto/32/26546_2.png) [@jmpinto](https://onehack.st/u/jmpinto)\
**Post date:** [March 14, 2020, 11:02am UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/11 "2020-03-14T11:02:12Z")

</div>

Hi  
Yes thats it

---

<div class="post-metadata">

**Author:** ![macmkboy](https://onehack.st/user_avatar/onehack.st/macmkboy/32/16918_2.png) [@macmkboy](https://onehack.st/u/macmkboy)\
**Post date:** [March 14, 2020, 4:21pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/12 "2020-03-14T16:21:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Crizalid](https://onehack.st/user_avatar/onehack.st/crizalid/32/32730_2.png) [@Crizalid](https://onehack.st/u/Crizalid)\
**Post date:** [March 14, 2020, 4:23pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/13 "2020-03-14T16:23:22Z")

</div>

Thank you so much sir ❤

---

<div class="post-metadata">

**Author:** ![Abd\_Shk](https://onehack.st/user_avatar/onehack.st/abd_shk/32/25814_2.png) [@Abd\_Shk](https://onehack.st/u/Abd_Shk)\
**Post date:** [March 17, 2020, 10:30am UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/14 "2020-03-17T10:30:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MikeBlueberry](https://onehack.st/user_avatar/onehack.st/mikeblueberry/32/34516_2.png) [@MikeBlueberry](https://onehack.st/u/MikeBlueberry)\
**Post date:** [March 17, 2020, 4:12pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/15 "2020-03-17T16:12:22Z")

</div>

@ [jmpinto](https://onehack.st/u/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.

---

<div class="post-metadata">

**Author:** ![Abd\_Shk](https://onehack.st/user_avatar/onehack.st/abd_shk/32/25814_2.png) [@Abd\_Shk](https://onehack.st/u/Abd_Shk)\
**Post date:** [March 17, 2020, 7:27pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/16 "2020-03-17T19:27:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ToughMeow](https://onehack.st/user_avatar/onehack.st/toughmeow/32/15743_2.png) [@ToughMeow](https://onehack.st/u/ToughMeow)\
**Post date:** [March 19, 2020, 8:18am UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/18 "2020-03-19T08:18:14Z")

</div>

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’  
ex:-  
!unzip ‘/gdrive/My Drive/file.zip’ -d ‘/gdrive/My Drive/Destination/’

---

<div class="post-metadata">

**Author:** ![Armin](https://onehack.st/user_avatar/onehack.st/armin/32/49874_2.png) [@Armin](https://onehack.st/u/Armin)\
**Post date:** [April 1, 2020, 4:20am UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/19 "2020-04-01T04:20:49Z")

</div>

Thanks 😍

---

<div class="post-metadata">

**Author:** ![KillerAz1](https://onehack.st/user_avatar/onehack.st/killeraz1/32/18851_2.png) [@KillerAz1](https://onehack.st/u/KillerAz1)\
**Post date:** [April 7, 2020, 8:27pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/20 "2020-04-07T20:27:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DavidGlover](https://onehack.st/user_avatar/onehack.st/davidglover/32/42268_2.png) [@DavidGlover](https://onehack.st/u/DavidGlover)\
**Post date:** [May 29, 2020, 2:54am UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/21 "2020-05-29T02:54:35Z")

</div>

> [@jmpinto](#):
>
> Jupyter Notebook

This is awesome way 🙂 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 🙂

---

<div class="post-metadata">

**Author:** ![agaramja\_garamja](https://onehack.st/user_avatar/onehack.st/agaramja_garamja/32/85868_2.png) [@agaramja\_garamja](https://onehack.st/u/agaramja_garamja)\
**Post date:** [June 17, 2020, 6:44pm UTC](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228/22 "2020-06-17T18:44:25Z")

</div>

Hey @jmpinto What the wrong with me can you suggest please. I want to download this file [http://dl.downloadly.ir/Files/Software/WinRAR\_5.90\_x86\_Downloadly.ir.exe](http://dl.downloadly.ir/Files/Software/WinRAR_5.90_x86_Downloadly.ir.exe) into my google drive but i can’t please help me and write the code for me please please please…

 ![What the wrong](https://onehack.st/uploads/default/original/3X/4/0/4071db11fb01a413b9fc08c20f29e94c69d8b8d4.jpeg)  
My code was:

import requests

file\_url = “[http://dl.downloadly.ir/Files/Software/WinRAR\_5.90\_x86\_Downloadly.ir.exe”](http://dl.downloadly.ir/Files/Software/WinRAR_5.90_x86_Downloadly.ir.exe%E2%80%9D)

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:

file.write(block)

[Next page](https://onehack.st/t/download-anything-to-google-drive-using-google-colab/73228.md?page=2)
