# 更改文件信息

File Management支持对文件夹和文件的部分信息做更改,另外也支持复制移动等操作,本节将介绍如何如何更改文件信息。

  • 准备阶段

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

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

File Management提供获取Hub列表 (opens new window) 接口,帮助您查询您的账号已注册哪些存储中心(Hub),您可以将文件上传到已注册的存储空间中。

# 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和path)可用于获取文件夹下所有文件信息 (opens new window); 由于在BIMFACE中,项目id和根文件夹id相同,您也可直接跳过这一步,将项目Id作为parentId填入相关的接口参数。

# HTTP请求示例

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

# HTTP响应示例

# 响应 200
{
  "code" : "bimfaceservice-0000",
  "data" : {
    "appKey" : "odatvZYUSAWMbdUjTU8HoZXB9tFt6123",
    "createTime" : "2022-02-02 02:02:02",
    "fileItemId" : "10000000006016",
    "folder" : false,
    "id" : "10000000006016",
    "length" : 0,
    "md5" : null,
    "name" : "/",
    "parentId" : null,
    "path" : "/",
    "physicalIndex" : null,
    "projectId" : "10000000006016",
    "status" : "success",
    "storeId" : null,
    "suffix" : null,
    "updateTime" : "2022-02-02 02:02:02",
    "uploadMode" : null,
    "version" : 1
  },
  "message" : null
}

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

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

下列接口将展示项目内所有文件夹和文件的列表,该接口支持您搜索文件夹名(无需完整名,输入关键字即可),或根据文件格式、文件创建时间筛选所需的文件夹或文件。

# 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"
}

# 5. 更改文件信息

在上一步,您已经得到了项目下的文件夹列表和部分文件的列表,如果您的文件在项目根目录下,例如您希望查询的文件是“BIMFACE示例图纸",那么您可以记录下文件id(fileItemId),通过文件重命名 (opens new window)接口修改该文件的名字。

如果您的文件在更深层级,例如在文件夹"bdfs文件夹测试"下,您需要重复上一步,继续调用接口获取文件夹下的所有文件 (opens new window),知道查询到特定的文件Id。

# HTTP请求示例

# 请求 path
PATCH https://api.bimface.com/bdfs/data/v1/projects/10000000006016/fileItems
# 请求 header
"Authorization: Bearer cn-e9725999-0b36-4c0e-bdca-38ea88888888"
# 请求 body
{
  "fileItemId" : "193888881377777",
  "name" : "新图纸.dwg",
}

# HTTP响应示例

# 响应 200
{
  "code" : "success",
  "data" : {
    "appKey" : "odatvZYUSAWMbdUjTU8HoZXB9tFt6123",
    "createTime" : "2022-02-02 02:02:02",
    "fileItemId" : "193888881377777",
    "folder" : false,
    "id" : "193888881377777",
    "length" : 345345345,
    "md5" : "sdfhskbvnksdiuewriusbndskudf",
    "name" : "新图纸.dwg",
    "parentId" : "10000000006016",
    "physicalIndex" : "a72eaf22f4214a6384429f78b690c983",
    "projectId" : "10000000006016",
    "status" : "success",
    "storeId" : "10000000021156",
    "suffix" : "dwg",
    "updateTime" : "2022-02-02 02:02:02",
    "uploadMode" : "GENERAL",
    "version" : 1
  },
  "message" : "success"
}