【问题标题】:Download google drive folder's file via wget通过 wget 下载 google drive 文件夹的文件
【发布时间】:2017-03-29 05:18:06
【问题描述】:

我想通过 wget 下载 google drive 文件夹文件,怎么可能?

我在 google 驱动器中有文件夹 version,并且在该版本文件夹中有我的移动应用程序的所有版本 apk 文件。

这样的文件夹树

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

我想通过传递版本名称来下载。谷歌驱动器和wget可以吗?我已经制作了文件夹Public on the web - Any on the Internet

【问题讨论】:

标签: google-drive-api wget


【解决方案1】:

您可以使用 wget 下载旧版本文件。要下载旧版本文件,需要访问令牌、文件 ID 和修订 ID 作为材料。获取材料的方法如下。 wget 用于所有方法。

1。访问令牌

参考:https://developers.google.com/identity/protocols/OAuth2

这是我与从 Google OAuth2 检索访问令牌相关的旧答案。 Refresh Google drive access__token如果对你有用,我很高兴。

2。文件 ID

为了检索文件 ID,它使用 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

由此,您可以在out.txt 中找到文件名的FileID。如果有多个同名文件,请选择其中一个。

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

3。修订 ID

为了检索修订 ID,它使用 drive.revisions.list 检索 FileID 的修订列表。

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

由此,您可以在out.txt 中找到文件ID 的RevisionID。请选择您想要的修订 ID。

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

4。修订 ID 文件

使用 drive.revisions.get 检索文件的修订 ID。

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

这样就可以检索到一个名为outputfilename的文件了。

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

【讨论】:

  • 你好@Tanaikem 我是脚本新手。你能告诉我如何使用 wget 从谷歌驱动器下载文件/文件夹吗?我正在使用 Ubuntu
  • @Gennaro Arguzzi 你好。很遗憾,我无法回答您关于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 的问题。这是因为我的技术不好。我对此深表歉意。那么如何将其发布为新问题?这样,它将帮助用户思考解决方案。如果您能合作解决您的问题,我很高兴。可以配合吗?
  • 嗨@Tanaike,我发布了一个关于此的问题。我希望尽快找到解决办法。非常感谢您的愿意
  • @Gennaro Arguzzi 感谢您的快速回复。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多