how to download large files faster from google drive

Alright, I feel like I have been creating a lot of detailed in-depth guides lately.

I am not complaining of course but today I feel like making a quick and dirty one.

Well, not dirty, but you know what I mean.

Today let’s learn how you can download a large file from your google drive faster using Windows PowerShell.

Usually when you try to download a large file from google drive directly you will receive a message like this.

Sometime google drive also splits your large file into multiple parts, zips them and then let’s you download them.

It’s not very convenient now is it.

This hasn’t happened to me but sometimes you cannot recover the big files properly when they are split into tiny chunks and may pose some errors.

So, today let me show you a neat trick that you can use to download large files from google drive directly using the Windows PowerShell, when a file is shared privately and requires you to authenticate.

Step 1: Fetching Your File ID

So the first thing that you need to do here is fetch the ID of the file you need to download.

It’s pretty simple and straight forward.

Follow these steps,

  1. Open a notepad.

You will be needing it to copy and paste IDs, authorization code and a PowerShell Script.

  • Open your browser and go to your google drive, open login with the account that has the file you wish to download.
  • Locate the file that you wish to download and select it.
  • Right click the file and click on “get shareable link”(refer the image below).
  • You don’t need to copy the entire link here; you only need the file ID that we will be using later.

The link will look like this: https://drive.google.com/file/d/XXXXX/view?usp=sharing

In this link, you only need to pay attention to the alphanumeric file ID, displayed by XXXXX here.

  • Copy the file ID in the notepad.

Step 2: Getting an OAuth Code

In this we will be needing an OAuth 2.0 authorization API key to allow PowerShell to gain access to the user protected data (the file that we want to download) on our google drive.

In order to achieve this.

  1. Visit OAuth 2.0 Playground by clicking here.
  2. On the developer’s webpage, in the “Select & authorize APIs” click on the “Drive API v3” option, and select the: https://www.googleapis.com/auth/drive.readonly option from the available options.

Refer this image.

  • Once selected click Authorize APIs button on the bottom right corner of the tab.
  • After you click on the Authorize APIs button you will be transferred to the google account login screen.
  • Select the same google account in which you have your file stored.
  • Allow Google OAuth 2.0 to access your drive if asked.
  • When you get redirected back to the OAuth 2.0 playground screen click on the “Exchange Authorization Code for Tokens” button as shown.
  • Copy the newly generated Access Token and save it on your notepad. You will be needing this in the next step.

Step 3: Downloading The File Using A Command Line Script

Okay it’s finally time to download your file.

This next step is pretty simple to be honest.

  • If you are on Linux, open the terminal and use the following command:
curl -H "Authorization: Bearer YYYYY" https://www.googleapis.com/drive/v3/files/XXXXX?alt=media -o ZZZZZ 
  • And if you are on windows, follow these steps.
  • Click on the Start button
  • Search “Powershell” on Windows search, right click and select “Run As Administrator“.
  • Click Yes on the next window and you will see the Windows PowerShell Console pop up.
  • On your notepad first copy this command,
Invoke-RestMethod -Uri https://www.googleapis.com/drive/v3/files/XXXXX?alt=media -Method Get -Headers @{"Authorization"="Bearer YYYYY"} -OutFile ZZZZZ 
  • Now replace the “XXXXX” in the commands with the file ID that we copied in the first step and replace “YYYYY” with the access token that we copied in the second step.
  • “ZZZZZ” is any name of your choice you would want to give to the downloaded file. So, replace it with the name of your choice, for example, “downloadedfile.mp4”, if you are downloading an mp4 file.

Well, that’s it.

Hit enter and see your file getting downloaded.

The completed downloads will get stored in “C:\Windows\System32” or the System32 folder.

Please remember this or you will keep fiddling in your downloads folder and will not be able to locate your file.

I am leaving a screenshot below as proof.

Try out this method and share with me your results.

Hit me back if in the comments if you have anymore queries or if you face any problem.

I will see ya in the next one.

Tada!