0

当我将文件夹拖到另一个位置时,

有什么方法可以让我知道这个活动,告诉我它从哪里到哪里?

4

1 回答 1

0

使用Google Drive Activity API获取有关用户 Google Drive 中所做更改的信息。

使用activity.query()

  • itemName根据您要使用此格式检查活动的文件/文件"items/FILE_ID"夹设置"items/FOLDER_ID"
  • 设置filterdetail.action_detail_case:MOVE获取移动操作活动

参考:


样品请求正文:

{
  "filter": "detail.action_detail_case:MOVE",
  "itemName": "items/1BNPRFAJgVMW-DF_sdEsF-_14X0xxxxx"
}

回复正文:

这将返回一个DriveActivity对象,该对象将在ActionDetail对象下包含一个Move对象。您可以参考->获取有关文件/文件夹的先前父文件夹的信息和->获取文件/文件夹的新父文件夹removedParentsdriveItemaddedParentsdriveItem

{
  "activities": [
    {
      "primaryActionDetail": {
        "move": {
          "addedParents": [
            {
              "driveItem": {
                "name": "items/1mF5a3gxiLzVIRe2dhY4W3Alfxxxx",
                "title": "NewFolder_Name",
                "folder": {
                  "type": "STANDARD_FOLDER"
                },
                "driveFolder": {
                  "type": "STANDARD_FOLDER"
                }
              }
            }
          ],
          "removedParents": [
            {
              "driveItem": {
                "name": "items/1lFzVvlBnBi-2o1VQGF5JDFRxxxxx",
                "title": "TESTFOLDER",
                "folder": {
                  "type": "STANDARD_FOLDER"
                },
                "driveFolder": {
                  "type": "STANDARD_FOLDER"
                }
              }
            }
          ]
        }
      },
        
      .....
        
      "targets": [
        {
          "driveItem": {
            "name": "items/11TrX6KcAJppWCj9GSUjSYn79Aqxxxx",
            "title": "CSVFOLDER",
            "folder": {
              "type": "STANDARD_FOLDER"
            },
            "mimeType": "application/vnd.google-apps.folder",
            .......
          }
        }
      ],
      "timestamp": "2021-08-12T16:10:24.744Z"
    }
  ]
}
于 2021-08-12T16:26:47.317 回答