Box.com api - "Does file exist" 检查

Box.com api - "Does file exist" check

为什么盒子 api 没有文件的 "exists" 方法?似乎是一个非常常见的用例。

因为没有直接的方法,所以怎么用API判断一个文件ID是否存在呢?

使用 API 您可以简单地 request the metadata for the file 使用该 ID。如果文件存在 并且 您可以访问它,那么将返回一个完整的文件对象。

要求:

curl https://api.box.com/2.0/files/FILE_ID
-H "Authorization: Bearer ACCESS_TOKEN"

回复:

200 OK

{
    "type": "file",
    "id": "5000948880",
    "etag": "3",
    "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc",
    "name": "tigers.jpeg",
    ...
}