聆客开放平台

# 文件夹操作API

# 获取文件夹文件列表

GET /v1/directories/file/list

# 请求类型(Content-Type)

  • application/json

# 请求参数

参数名 数据类型 必填 参数位置 参数说明
dirId String Y query 文件夹ID

# 返回结果

状态码 说明 返回值 响应
200 succeed FileItemResult

# 请求示例

GET /v1/directories/file/list?dirId=dirId
Content-Type: application/json

# 返回示例

成功:

Content-Type: */*

{
  "code": 200,
  "message": null,
  "data": [
    {
      "id": "id",
      "name": "name",
      "extension": "extension",
      "size": size,
      "version": version,
      "fileHash": "fileHash",
      "createdTime": "createdTime",
      "modifiedTime": "modifiedTime"
    }
  ],
  "date": 1657075350601,
  "total": 0,
  "count": 1
}

# 创建文件夹

POST /v1/directories/create

# 请求类型(Content-Type)

  • application/json

# 请求参数

参数名 数据类型 必填 参数位置 参数说明
name String Y body 文件夹名称
parentId String N body 父文件夹id,创建一级文件夹时留空
principalId String N body 文件夹主体id(创建一级文件夹时需要,parentId和principalId同时为空,表示在个人文档根路径下创建文件夹)
skip boolean N body 文件夹存在时是否忽略(默认为:false, 如果存在则返回错误)

# 返回结果

状态码 说明 返回值 响应
200 succeed DirectoryResponse
400 failure String
430002 文件夹已存在 String
430011 操作权限不足 String
430003 父文件夹不存在 String

# 请求示例

POST /v1/directories/create
Content-Type: application/json

{
"name": "directoryName", 
"parentId": "parentId",
"principalId": "principalId",
"skip": false
}

# 返回示例

成功:

Content-Type: */*

{
    "code": 200,
    "message": null,
    "data": {
        "id": "id",
        "name": "directoryName",
        "fullPath": "fullPath",
        "parentId": "parentId",
        "version": 0,
        "permissions": {
            "uploadable": true,
            "previewable": true,
            "deleteable": true,
            "shareable": true,
            "downloadable": true,
            "editable": true,
            "restoreable": true,
            "manageable": true,
            "lockable": false,
            "unlockable": false,
            "readable": true
        }
    },
    "date": 1635837588542
}

失败:

{
    "code": 400,
    "message": "该目录下已存在目录“directoryName”",
    "data": null,
    "date": 1635823240129
}

# 删除文件夹

POST /v1/directories/delete

# 请求类型(Content-Type)

  • application/json

# 请求参数

参数名 数据类型 必填 参数位置 参数说明
dirId String Y body 文件夹id

# 返回结果

状态码 说明 返回值 响应头 说明
200 succeed DirectoryResponse 目前只返回填充文件夹id
400 failure String
430011 操作权限不足 String
430003 文件夹不存在 String

# 请求示例

POST /v1/directories/delete
Content-Type: application/json

{
"dirId": "dirId"
}

# 返回示例

成功:

Content-Type: */*

{
    "code": 200,
    "message": null,
    "data": {
        "id": "id",
        "name": "directoryName",
        "fullPath": "fullPath",
        "parentId": "parentId",
        "version": 0,
        "permissions": {
            "uploadable": true,
            "previewable": true,
            "deleteable": true,
            "shareable": true,
            "downloadable": true,
            "editable": true,
            "restoreable": true,
            "manageable": true,
            "lockable": false,
            "unlockable": false,
            "readable": true
        }
    },
    "date": 1635837588542
}

失败:

{
    "code": 400,
    "message": "找不到资源,请刷新后重试",
    "data": null,
    "date": 1635840463893
}

# 重命名文件夹

POST /v1/directories/rename

# 请求类型(Content-Type)

  • application/json

# 请求参数

参数名 数据类型 必填 参数位置 参数说明
dirId String Y body 文件夹id
name String Y body 文件夹新名称

# 返回结果

状态码 说明 返回值 响应头 说明
200 succeed DirectoryResponse 目前只返回填充文件夹id
400 failure String
430002 文件夹已存在 String
430011 操作权限不足 String
430003 文件夹不存在 String

# 请求示例

POST /v1/directories/delete
Content-Type: application/json

{
"dirId": "dirId"
"name": "name"
}

# 返回示例

成功:

Content-Type: */*

{
    "code": 200,
    "message": null,
    "data": {
        "id": "id",
        "name": "directoryName",
        "fullPath": "fullPath",
        "parentId": "parentId",
        "version": 0,
        "permissions": {
            "uploadable": true,
            "previewable": true,
            "deleteable": true,
            "shareable": true,
            "downloadable": true,
            "editable": true,
            "restoreable": true,
            "manageable": true,
            "lockable": false,
            "unlockable": false,
            "readable": true
        }
    },
    "date": 1635837588542
}

失败:

{
    "code": 400,
    "message": "找不到资源,请刷新后重试",
    "data": null,
    "date": 1635840463893
}

# 锁定文件夹

POST /v1/directories/lock

# 请求类型(Content-Type)

  • application/json

# 请求参数

参数名 数据类型 必填 参数位置 参数说明
dirId String Y body 文件夹id

# 返回结果

状态码 说明 返回值 响应头 说明
200 succeed DirectoryResponse 目前只返回填充文件夹id
400 failure String
430011 操作权限不足 String
430003 文件夹不存在 String
430020 文件夹不安全 String
430017 文件夹或父文件夹被锁定 String

# 请求示例

POST /v1/directories/lock
Content-Type: application/json

{
"dirId": "dirId"
}

# 返回示例

成功:

Content-Type: */*

{
    "code": 200,
    "message": null,
    "data": {
        "id": "dirId",
        "name": null,
        "fullPath": null,
        "parentId": null,
        "version": null,
        "permissions": null
    },
    "date": 1636698607077
}

失败:

{
    "code": 430017,
    "message": "文件夹或父文件夹被锁定",
    "data": null,
    "date": 1636699196421
}

# 解锁文件夹

POST /v1/directories/unlock

# 请求类型(Content-Type)

  • application/json

# 请求参数

参数名 数据类型 必填 参数位置 参数说明
dirId String Y body 文件夹id

# 返回结果

状态码 说明 返回值 响应头 说明
200 succeed DirectoryResponse 目前只返回填充文件夹id
400 failure String
430011 操作权限不足 String
430003 文件夹不存在 String
430020 文件夹不安全 String
430017 文件夹或父文件夹被锁定 String

# 请求示例

POST /v1/directories/unlock
Content-Type: application/json

{
"dirId": "dirId"
}

# 返回示例

成功:

Content-Type: */*

{
    "code": 200,
    "message": null,
    "data": {
        "id": "dirId",
        "name": null,
        "fullPath": null,
        "parentId": null,
        "version": null,
        "permissions": null
    },
    "date": 1636698607077
}

失败:

{
    "code": 430017,
    "message": "文件夹或父文件夹被锁定",
    "data": null,
    "date": 1636699196421
}

# 文件夹授权

POST /v1/directories/authorize

# 请求类型(Content-Type)

  • application/json

# 请求参数

参数名 数据类型 必填 参数位置 参数说明
dirId String Y body 文件夹id
roleIds List Y body 权限角色id
authTarget List Y body 授权目标id
targetType Integer Y body 授权目标类型(1:用户; 2:用户组)

# 返回结果

状态码 说明 返回值 响应头 说明
200 succeed String Authorize success
400 failure String
430011 操作权限不足 String
430003 文件夹不存在 String

# 请求示例

POST /v1/directories/authorize
Content-Type: application/json

{
"dirId": "dirId",
"roleIds": ["roleIds"],
"authTarget": ["authTarget"],
"targetType": 1
}

# 返回示例

成功:

Content-Type: */*

{
    "code": 200,
    "message": null,
    "data": Authorize success,
    "date": 1636698607077
}

失败:

{
    "code": 430011,
    "message": "操作权限不足",
    "data": null,
    "date": 1636699196421
}

# 移除文件夹授权

POST /v1/directories/authorize/remove

# 请求类型(Content-Type)

  • application/json

# 请求参数

参数名 数据类型 必填 参数位置 参数说明
dirId String Y body 文件夹id
target String Y body 移除授权的目标id
targetType Integer Y body 目标类型(1:用户; 2:用户组)

# 返回结果

状态码 说明 返回值 响应头 说明
200 succeed String Authorize remove success
400 failure String
430011 操作权限不足 String
430003 文件夹不存在 String

# 请求示例

POST /v1/directories/authorize/remove
Content-Type: application/json

{
"dirId": "dirId",
"target": "target",
"targetType": 1
}

# 返回示例

成功:

Content-Type: */*

{
    "code": 200,
    "message": null,
    "data": Authorize remove success,
    "date": 1636698607077
}

失败:

{
    "code": 430011,
    "message": "操作权限不足",
    "data": null,
    "date": 1636699196421
}