BIM 360 Docs 如何复制文件

Posted

技术标签:

【中文标题】BIM 360 Docs 如何复制文件【英文标题】:BIM 360 Docs how to copy file 【发布时间】:2020-08-08 08:58:59 【问题描述】:

versions API endpoint 提到它可以用来制作文档的副本。看来 copyFrom 参数是源文件 urn 的 http 编码值。示例中的 Relations.item.data.type.itemsid 的值是多少?我是否需要先创建一个空文件对象,然后在请求正文中提供该 ID?

【问题讨论】:

【参考方案1】:

项目 id 是您要从中复制的文件的数据管理 API 的 id。您可以通过以下方式获取:

https://developer.autodesk.com/en/docs/data/v2/reference/http/hubs-hub_id-projects-project_id-GET https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-versions-version_id-item-GET/

您不必创建空文件对象,只需调用 API:https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-versions-POST/

例如,

这是一个存储在Docs中的RVT模型,其项目数据如下:


   "type": "items",
   "id": "urn:adsk.wipprod:dm.lineage:rH_L4XJsTmeiYA4ixCVNAA",   //!<<< Item id
   "attributes": 
       "displayName": "rac_basic_sample_project.rvt",
       "createTime": "2019-09-25T06:56:26.0000000Z",
       //...
       "lastModifiedTime": "2019-09-25T06:56:27.0000000Z",
       //...
       "hidden": false,
       "reserved": false,
       "extension": 
           "type": "items:autodesk.bim360:File",
           "version": "1.0",
           "schema": 
               "href": "https://developer.api.autodesk.com/schema/v1/versions/items:autodesk.bim360:File-1.0"
           ,
           "data": 
               "sourceFileName": "rac_basic_sample_project.rvt"
           
       
   ,


   //...

然后调用https://developer.api.autodesk.com/data/v1/projects/PROJECT_ID/items/urn:adsk.wipprod:dm.lineage:rH_L4XJsTmeiYA4ixCVNAA/versions 获取其版本记录:


   "type": "versions",
   "id": "urn:adsk.wipprod:fs.file:vf.rH_L4XJsTmeiYA4ixCVNAA?version=1",   //!<<< Version id
   "attributes": 
       "name": "rac_basic_sample_project.rvt",
       "displayName": "rac_basic_sample_project.rvt",
       "createTime": "2019-09-25T06:56:26.0000000Z",
       //...
       "lastModifiedTime": "2019-09-25T06:57:54.0000000Z",
       //...
       "versionNumber": 1,
       "storageSize": 17813504,
       "fileType": "rvt",
       "extension": 
           "type": "versions:autodesk.bim360:File",
           "version": "1.0",
           "schema": 
               "href": "https://developer.api.autodesk.com/schema/v1/versions/versions:autodesk.bim360:File-1.0"
           ,
           "data": 
               "processState": "PROCESSING_COMPLETE",
               "extractionState": "SUCCESS",
               "splittingState": "NOT_SPLIT",
               "reviewState": "NOT_IN_REVIEW",
               "revisionDisplayLabel": "1",
               "sourceFileName": "rac_basic_sample_project.rvt"
           
       
   ,

   //...  

现在您想将此项目的特定版本urn:adsk.wipprod:fs.file:vf.rH_L4XJsTmeiYA4ixCVNAA?version=1 复制到另一个文件夹urn:adsk.wipprod:fs.folder:co.0xaYa2rVTJuFiz7rxLCOQQ。因此,API 调用将如下所示:

注意。版本ID的URL安全格式是urn%3Aadsk.wipprod%3Afs.file%3Avf.rH_L4XJsTmeiYA4ixCVNAA%3Fversion%3D1

POST https://developer.api.autodesk.com/data/v1/projects/PROJECT_ID/items?copyFrom=urn%3Aadsk.wipprod%3Afs.file%3Avf.rH_L4XJsTmeiYA4ixCVNAA%3Fversion%3D1


   "jsonapi": 
     "version": "1.0"
   ,
   "data": 
     "type": "items",
     "id": "urn:adsk.wipprod:dm.lineage:rH_L4XJsTmeiYA4ixCVNAA",
     "relationships": 
      "tip":
            "data":
               "type":"versions",
               "id":"1"
            
         ,
         "parent": 
             "data": 
                 "type": "folders",
                 "id": "urn:adsk.wipprod:fs.folder:co.0xaYa2rVTJuFiz7rxLCOQQ"  //!<<< The folder we want to put this file
             
         
     
   ,
   "included":[
      
         "type":"versions",
            "id":"1",
            "attributes":
               "name":"rac_basic_sample_project.rvt"   //!<<< Version name
            
      
   ]

希望对你有帮助!

【讨论】:

感谢您提供此信息。如果这将被添加到 Forge 文档中,请注意“type:versions”“id:1”指的是 API 模式版本,而不是被复制的文件。..

以上是关于BIM 360 Docs 如何复制文件的主要内容,如果未能解决你的问题,请参考以下文章

BIM 360 项目创建、模板重复文件夹(更新请求)

云处理后如何将 DWG 保存到 BIM 360 Docs

使用 Javascript 下载 BIM360 Docs 文件

如何在 BIM 360 上获取模型之间的链接?

从 BIM360 Doc Plans 文件夹中的 API 下载文件

如何将 BIM 360 文件的内容作为文件流读取并将其写入另一个流