【问题标题】:Retrieving web view link of a Google shared drive folder检索 Google 共享驱动器文件夹的网络视图链接
【发布时间】:2020-11-04 13:38:47
【问题描述】:

我正在尝试获取 google 的 webviewlink 共享

API:https://www.googleapis.com/drive/v3/files

我无法获取特定共享驱动器文件夹的 webviewlink。

我的输入将是文件夹 ID:

{
   "id": "1Vat7pdwnpg8i2xMzhic4dOVbadZNv0OJ"
}

我怎样才能做到这一点?

【问题讨论】:

  • 您现在得到的回应是什么?它是什么类型的文件?并非所有文件类型都会创建 Web 链接
  • 它是一个文件夹 ID,我只获取子文件夹的详细信息。例如。 "name": "Google Drive, Notes and Attachments", "parents": ["1Vat7pdwnpg8i2xMzhic4dOVbadZNv0OJ"], "webViewLink": "drive.google.com/drive/folders/…" 但我需要 webViewLink 正在传递的文件夹 id

标签: google-api google-drive-api


【解决方案1】:

没有看到确切的要求,您很难提供帮助,但我可以说这似乎可以正常工作。我可以获取与我共享的 google 驱动器目录的记录,该目录包含一个 web 视图链接,该链接与我发送的文件 ID 相同。

请求

curl \
  'https://www.googleapis.com/drive/v3/files/1nhladm_nRRee6rVER9ZA5QqnyKwfG7l?fields=*&key=[YOUR_API_KEY]' \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --compressed

回复

{
 "kind": "drive#file",
 "id": "1nhladm_nRRee6rVER9ZA5QqnyKwfG7l",
 "name": "ML GDE Model Deployment Project",
 "mimeType": "application/vnd.google-apps.folder",
 "starred": false,
 "trashed": false,
 "explicitlyTrashed": false,
 "parents": [
  "1OYYiVmqFp9ZvuRSuVgC_ihkdYirLnu"
 ],
 "spaces": [
  "drive"
 ],
 "version": "461",
 "webViewLink": "https://drive.google.com/drive/folders/1nhladm_nRRee6rVER9ZA5QqnyKwfG7li",
 "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.folder+shared",
 "hasThumbnail": false,
 "thumbnailVersion": "0",
 "viewedByMe": false,
 "createdTime": "2020-04-02T04:21:47.275Z",
 "modifiedTime": "2020-11-02T13:58:51.042Z",
 "modifiedByMe": false,
 "owners": [
  {
   .....
  }
 ],
 "lastModifyingUser": {
  "kind": "drive#user",
  
 },
 "shared": true,
 "ownedByMe": false,
 "capabilities": {
  "canAddChildren": false,
  "canAddMyDriveParent": false,
  "canChangeCopyRequiresWriterPermission": false,
  "canChangeViewersCanCopyContent": false,
  "canComment": false,
  "canCopy": false,
  "canDelete": false,
  "canDownload": true,
  "canEdit": false,
  "canListChildren": true,
  "canModifyContent": false,
  "canMoveChildrenWithinDrive": false,
  "canMoveItemIntoTeamDrive": false,
  "canMoveItemOutOfDrive": false,
  "canMoveItemWithinDrive": false,
  "canReadRevisions": false,
  "canRemoveChildren": false,
  "canRemoveMyDriveParent": true,
  "canRename": false,
  "canShare": false,
  "canTrash": false,
  "canUntrash": false
 },
 "viewersCanCopyContent": true,
 "copyRequiresWriterPermission": false,
 "writersCanShare": true,
 "folderColorRgb": "#8f8f8f",
 "quotaBytesUsed": "0",
 "isAppAuthorized": false
}

此请求的 Web 视图链接是 https://drive.google.com/drive/folders/1nhladm_nRRee6rVER9ZA5QqnyKwfG7l,与我发送它的文件 ID 相同。

文件 ID 会随着 Web 视图链接的变化而变化,并且它们可能不同步。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-09
    • 2013-01-23
    • 2011-04-21
    • 2021-11-05
    • 1970-01-01
    相关资源
    最近更新 更多