# 删除文件

当您不再需要保留上传的文件时,您可以手动删除单个或多个文件或文件夹。本章节将介绍如何删除文件。

  • 准备阶段

在上传文件前,您需要获取有效的Access Token, 有关Access Token 的详细说明和具体操作,请参见 Access Token (opens new window)

# 1. 查找文件所属的Hub空间

File Management提供获取Hub列表 (opens new window) 接口,帮助您查询您的账号已注册哪些存储中心(Hub),您的文件位于这些存储空间中,在删除文件前您需要获取HubId。

# HTTP请求示例

# 请求 path
GET https://api.bimface.com/bdfs/domain/v1/hubs
# 请求 header
"Authorization: Bearer cn-e9725999-0b36-4c0e-bdca-38ea88888888"

# HTTP响应示例

# 响应 200
{
  "code" : "success",
  "data" : [ {
    "appKey" : "odatvZYUSAWMbdUjTU8HoZXB9tFt6123",
    "createTime" : "2022-02-02 02:02:02",
    "id" : "10000000000060002",
    "info" : "BIMFACE的hub",
    "name" : "BIMFACE",
    "tenantCode" : "BIMFACE",
    "updateTime" : "2022-02-02 02:02:02"
  } ],
  "message" : "success"
}

# 2. 查找到文件所属的Project

上一步您查找到了您账户注册的存储中心(Hub),假设您已经注册了"BIMFACE"的存储中心,请记住上一节响应正文中的id字段,它代表了HubId(10000000000060002)。

您需要在接口获取项目列表 (opens new window)中使用HubId,来获取可使用的项目列表(Project),,您将在该列表中选择一个项目,查询该项目下的文件信息。

# HTTP请求示例

# 请求 path
GET https://api.bimface.com/bdfs/domain/v1/hubs/10000000000060002/projects
# 请求 header
"Authorization: Bearer cn-e9725999-0b36-4c0e-bdca-38ea88888888"

# HTTP响应示例

# 响应 200
{
  "code" : "success",
  "data" : [ {
    "appKey" : "odatvZYUSAWMbdUjTU8HoZXB9tFt6123",
    "createTime" : "2022-02-02 02:02:02",
    "hubId" : "10000000000060002",
    "id" : "10000000006016",
    "info" : "图纸对比的项目中心",
    "name" : "图纸对比",
    "tenantCode" : "BIMFACE",
    "thumbnail" : "https://static.bimface.com/bdfs/project/thumbnail/8e21fc91481e42ce805f0db938e04958_200X150.png",
    "type" : "NORMAL",
    "updateTime" : "2022-02-02 02:02:02"
  } ,
    {
    "appKey" : "odatvZYUSAWMbdUjTU8HoZXB9tFt6123",
    "createTime" : "2022-02-02 02:02:02",
    "hubId" : "10000000000060002",
    "id" : "10000000005555",
    "info" : "由BIMFACE默认创建的项目,您可以在项目中根据自己的需要存放模型、图纸文件,并进行转换、集成、对比、场景搭建等操作,实现基于云端的可视化浏览与应用开发",
    "name" : "BIMFACE默认项目",
    "tenantCode" : "BIMFACE",
    "thumbnail" : "https://static.bimface.com/bdfs/project/thumbnail/8e21fc91481e42ce805f0db938e04958_200X150.png",
    "type" : "NORMAL",
    "updateTime" : "2022-02-02 02:02:02"
  }],
  "message" : "success"
}

# 3. 查找文件所属的文件夹

上一步您已经找到了项目列表,假设您的文件隶属于 "图纸对比"项目,请记住该项目的id(10000000006016),您将在获取文件夹下的所有文件 (opens new window)接口中使用projectId。

下列接口将展示项目内所有文件夹和文件的列表,该接口支持您搜索文件夹名(无需完整名,输入关键字即可),

或根据文件格式、文件创建时间筛选所需的文件夹或文件,然后记录下需要删除的文件Id.

# HTTP请求示例

# 请求 path
POST https://api.bimface.com/bdfs/data/v1/projects/10000000006016/folders/contents
# 请求 header
"Authorization: Bearer cn-e9725999-0b36-4c0e-bdca-38ea88888888"
# 请求 body
{
  "endTime" : "2022-02-04 02:02:02",
  "excludeFolder" : false,
  "parentId" : "10000000006016",
  "startTime" : "2022-02-01 02:02:02",
  "suffix" : "rvt",
  "useFuzzySearch" : false,
}

# HTTP响应示例

# 响应 200
{
  "code" : "success",
  "data" : [
{
    "appKey" : "odatvZYUSAWMbdUjTU8HoZXB9tFt6123",
    "createTime" : "2022-02-02 02:02:02",
    "fileItemId" : "1938888813662976",
    "folder" : true,
    "id" : "1938888813662976",
    "length" : 0,
    "md5" : null,
    "name" : "dwg图纸测试",
    "parentId" : "10000000006016",
    "physicalIndex" : null,
    "projectId" : "10000000006016",
    "status" : "success",
    "storeId" : null,
    "suffix" : null,
    "updateTime" : "2022-02-02 02:02:02",
    "uploadMode" : null,
    "version" : 1
  },
  {
    "appKey" : "odatvZYUSAWMbdUjTU8HoZXB9tFt6123",
    "createTime" : "2022-02-02 02:02:02",
    "fileItemId" : "193888881355555",
    "folder" : true,
    "id" : "193888881355555",
    "length" : 0,
    "md5" : null,
    "name" : "bdfs文件夹测试",
    "parentId" : "10000000006016",
    "physicalIndex" : null,
    "projectId" : "10000000006016",
    "status" : "success",
    "storeId" : null,
    "suffix" : null,
    "updateTime" : "2022-02-02 02:02:02",
    "uploadMode" : null,
    "version" : 1
  },
  {
    "appKey" : "odatvZYUSAWMbdUjTU8HoZXB9tFt6123",
    "createTime" : "2022-02-02 02:02:02",
    "fileItemId" : "193888881366666",
    "folder" : false,
    "id" : "193888881366666",
    "length" : 345345345,
    "md5" : "sdfhskbvnksdiuewriusbndskudf",
    "name" : "BIMFACE示例文件.rvt",
    "parentId" : "10000000006016",
    "physicalIndex" : "a72eaf22f4214a6384429f78b690c983",
    "projectId" : "10000000006016",
    "status" : "success",
    "storeId" : "10000000021156",
    "suffix" : "rvt",
    "updateTime" : "2022-02-02 02:02:02",
    "uploadMode" : "GENERAL",
    "version" : 1
  },
  {
    "appKey" : "odatvZYUSAWMbdUjTU8HoZXB9tFt6123",
    "createTime" : "2022-02-02 02:02:02",
    "fileItemId" : "193888881377777",
    "folder" : false,
    "id" : "193888881377777",
    "length" : 345345345,
    "md5" : "sdfhskbvnksdiuewriusbnddshih",
    "name" : "BIMFACE示例图纸.dwg",
    "parentId" : "10000000006016",
    "physicalIndex" : "a72eaf22f4214a6384429f777777",
    "projectId" : "10000000006016",
    "status" : "success",
    "storeId" : "1000000007777",
    "suffix" : "rvt",
    "updateTime" : "2022-02-02 02:02:02",
    "uploadMode" : "GENERAL",
    "version" : 1
  }],
  "message" : "success"
}

# 4. 删除项目

上面三步,您分别获取了hubId,projectId,folderId和fileItemId,File Management支持删除项目、文件夹、文件这三个层级的存储空间。

如果您希望直接删除不需要的项目以及其包含的所有文件,举例说明,如果您希望删除第二步中查询到的"图纸对比"项目,您可以使用删除项目 (opens new window)接口。

# HTTP请求示例

# 请求 path
DELETE https://api.bimface.com/bdfs/domain/v1/hubs/10000000000060002/projects/10000000006016
# 请求 header
"Authorization: Bearer cn-e9725999-0b36-4c0e-bdca-38ea88888888"

# HTTP响应示例

# 响应 200
{
  "code" : "success",
  "data" : {
    "appKey" : "odatvZYUSAWMbdUjTU8HoZXB9tFt6123",
    "createTime" : "2022-02-02 02:02:02",
    "hubId" : "10000000000060002",
    "id" : "10000000006016",
    "info" : "BIMFACE的项目",
    "name" : "图纸对比",
    "tenantCode" : "BIMFACE",
    "thumbnail" : "https://static.bimface.com/bdfs/project/thumbnail/8e21fc91481e42ce805f0db938e04958_200X150.png",
    "type" : "NORMAL",
    "updateTime" : "2022-02-02 02:02:02"
  },
  "message" : "success"
}

# 5. 删除文件夹

如果您希望删除某个文件夹及其包含的所有文件,举例说明,如果您希望删除第三步中查询到的”dwg图纸测试“文件夹,

您需要获取projectId(10000000006016)以及该文件夹folderId(1938888813662976), 然后使用删除文件夹 (opens new window)接口。

# HTTP请求示例

# 请求 path
DELETE https://api.bimface.com/bdfs/data/v1/projects/10000000006016/folders?folderId=1938888813662976&path=%2FBDFS
# 请求 header
"Authorization: Bearer cn-e9725999-0b36-4c0e-bdca-38ea88888888"

# HTTP响应示例

# 响应 200
{
  "code" : "success",
  "message" : "success"
}

# 6. 删除文件

BDFS支持批量删除文件,如果您希望删除某个文件夹及其包含的所有文件,举例说明,如果您希望删除第三步中查询到的"BIMFACE示例图纸","BIMFACE示例文件"文件,

您需要获取文件所在的项目projectId(10000000006016)以及文件Id(193888881377777、193888881366666), 然后使用批量删除文件 (opens new window)接口。

# HTTP请求示例

# 请求 path
https://api.bimface.com/bdfs/data/v1/projects/10000000006016/fileItems
# 请求 header
"Authorization: Bearer cn-e9725999-0b36-4c0e-bdca-38ea88888888"
# 请求 body
[
    "193888881377777",
    "193888881366666",
]

# HTTP响应示例

# 响应 200
{
  "code" : "success",
  "message" : "success"
}