0

I want to download google drive folders file via wget how it is possible?

I have folder version in google drive and in that version folder all version apk file of my mobile app.

Folder tree like this

Version : -> mobileapp1.apk
          -> mobileapp2.apk
          -> mobileapp3.apk

And I want to download by passing version name. Is it possible with google drive and wget? I have already make folder Public on the web - Anyone on the Internet

LOKESH
  • 1,303
  • 1
  • 16
  • 29
  • See this answer for a way to download via `curl` (works as of 2018): https://stackoverflow.com/a/32742700/ – User Sep 06 '18 at 09:00

1 Answers1

0

You can download old version files using wget. In order to download old version files, Access token, File ID and Revision ID are required as the materials. The methods for retrieving the materials are follows. wget is used for all methods.

1. Access token

Reference : https://developers.google.com/identity/protocols/OAuth2

This is my old answer related to retrieving access token from Google OAuth2. Refresh Google drive access__token If this is useful for you, I'm glad.

2. File ID

In order to retrieve file ID, it searches it from file name using drive.files.list.

wget -q --header='Authorization: Bearer ### Access token ###' \
    'https://www.googleapis.com/drive/v3/files?q=name="### FileName ###"&fields=files(id,name)' \
    -O out.txt

By this, you can find FileID for the FileName in the out.txt. If there are several files with same name, please select one of them.

Reference : https://developers.google.com/drive/v3/reference/files/list

3. Revision ID

In order to retrieve revision ID, it retrieves revision list for the FileID using drive.revisions.list.

wget -q --header='Authorization: Bearer ### Access token ###' \
    'https://www.googleapis.com/drive/v3/files/### FileID ###/revisions?fields=revisions(id%2CmodifiedTime)' \
    -O out.txt

By this, you can find RevisionID for the FileID in the out.txt. Please select revision ID you want.

Reference : https://developers.google.com/drive/v3/reference/revisions/list

4. File for Revision ID

Retrieves File for Revision ID using drive.revisions.get.

wget -q --header='Authorization: Bearer ### Access token ###' \
    "https://www.googleapis.com/drive/v3/files/### FileID ###/revisions/### RevisionID ###?alt=media" \
    -O outputfilename

By this, a file with name of outputfilename can be retrieved.

Reference : https://developers.google.com/drive/v3/reference/revisions/get

Community
  • 1
  • 1
Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • Hello @Tanaikem I'm a newbie in scripting. Can you tell me how to download file/folder from google drive by using wget please? I'm using Ubuntu – Gennaro Arguzzi Mar 23 '21 at 09:21
  • @Gennaro Arguzzi Hello. Unfortunately, I cannot answer your question of `Hello @Tanaikem I'm a newbie in scripting. Can you tell me how to download file/folder from google drive by using wget please? I'm using Ubuntu`. This is due to my poor skill. I deeply apologize for this. So how about posting it as new question? By this, it will help users think of the solution. If you can cooperate to resolve your issue, I'm glad. Can you cooperate to do it? – Tanaike Mar 23 '21 at 12:22
  • 1
    Hi @Tanaike, I posted a question about that. I hope to find a solution as soon as possible. Thank you very much for your willingness – Gennaro Arguzzi Mar 23 '21 at 12:47
  • @Gennaro Arguzzi Thank you for your quick reply. – Tanaike Mar 23 '21 at 12:50