【问题标题】:Getting all locked files using the BOX API (BOX.com)使用 BOX API (BOX.com) 获取所有锁定的文件
【发布时间】:2015-05-11 19:33:44
【问题描述】:

我正在尝试找到一种解决方案来搜索/列出 BOX (BOX.com) 中的所有锁定文件。 由于这似乎无法通过用户界面实现,因此我调查了 Rest API。

我找不到使用 API 搜索所有锁定文件的方法。 我无法遍历 API。 我无法使用“fields=lock”作为参数进行通配符搜索。

目前我可以查询单个文件是否被锁定:

https://api.box.com/2.0/files/26802142333?fields=lock

返回

{
    "type": "file",
    "id": "26802142333",
    "etag": "462",
    "lock": {
        "type": "lock",
        "id": "22148533",
        "created_by": {
            "type": "user",
            "id": "201274112",
            "name": "Robert Wunsch",
            "login": "rwunsch@sapient.com"
        },
        "created_at": "2015-05-11T11:36:08-07:00",
        "expires_at": null,
        "is_download_prevented": false
    }
}

我可以使用“fields=lock”参数创建搜索,并使用查询进行搜索,例如包含“xls”的所有内容:

https://api.box.com/2.0/search?query=xls&fields=lock

返回

...,
{
            "type": "file",
            "id": "29299819893",
            "etag": "0",
            "lock": null
        },
        {
            "type": "file",
            "id": "26004664251",
            "etag": "0",
            "lock": null
        },
        {
            "type": "file",
            "id": "26004640461",
            "etag": "0",
            "lock": null
        },
        {
            "type": "file",
            "id": "29618844701",
            "etag": "3",
            "lock": {
                "type": "lock",
                "id": "22002195",
                "created_by": {
                    "type": "user",
                    "id": "202820453",
                    "name": "Robert Wunsch",
                    "login": "gincalua@googlemail.com"
                },
                "created_at": "2015-05-06T05:33:28-07:00",
                "expires_at": null,
                "is_download_prevented": false
            }
        },
        {
            "type": "file",
            "id": "26004659155",
            "etag": "0",
            "lock": null
        },
        {
            "type": "file",
            "id": "29063166840",
            "etag": "0",
            "lock": null
        },
...

如何搜索锁定的文件?

感谢您的帮助!

【问题讨论】:

    标签: locking box-api box boxapiv2


    【解决方案1】:

    我不相信 API 有办法有效地检索所有锁定的文件。

    唯一可靠的解决方案是遍历整个文件夹树并检查每个文件是否已锁定。但是,如果您有很多文件或非常深的层次结构,这会很慢,因为您需要为每个文件夹发出至少一个 API 请求。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-03
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 2023-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多