简体   繁体   English

BIM 360 Docs 如何复制文件

[英]BIM 360 Docs how to copy file

The versions API endpoint mentions that it can be used to make a copy of a document. API 端点版本提到它可用于制作文档的副本。 It appears that the copyFrom parameter is the http encoded value of the source file urn.看来 copyFrom 参数是源文件 urn 的 http 编码值。 What is the value of relationships.item.data.type.itemsid in the example?示例中的 Relations.item.data.type.itemsid 的值是多少? Do I need to first create an empty file object and then provide that Id in the request body?我是否需要先创建一个空文件 object 然后在请求正文中提供该 ID?

The item id is the id of Data Management API the file that you want to copy from it.项目 id 是您要从中复制的文件的数据管理 API 的 id。 You can obtain it via calling:您可以通过调用获得它:

You don't have to create an empty file object, just call the API: https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-versions-POST/您不必创建一个空文件object,只需调用API:https_forge.autodesk.com/en/docs/data/v2/POSThttp-project/

For example,例如,

Here is an RVT model with stored in Docs, and its item data is the below:这是一个存储在Docs中的RVT model,其项目数据如下:

{
   "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"
           }
       }
   },


   //...
}

Then call https://developer.api.autodesk.com/data/v1/projects/ {PROJECT_ID}/items/urn:adsk.wipprod:dm.lineage:rH_L4XJsTmeiYA4ixCVNAA/versions to get its version records:然后调用https://developer.api.autodesk.com/data/v1/projects/ {PROJECT_ID}/items/urn:adsk.wipprod:dm.lineage:rH_L4XJsTmeiYA4ixCNAA 版本记录:

{
   "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"
           }
       }
   },

   //...  
}

Now you want to copy a specific version urn:adsk.wipprod:fs.file:vf.rH_L4XJsTmeiYA4ixCVNAA?version=1 of this item to another folder urn:adsk.wipprod:fs.folder:co.0xaYa2rVTJuFiz7rxLCOQQ .现在您想将此项的特定版本urn:adsk.wipprod:fs.file:vf.rH_L4XJsTmeiYA4ixCVNAA?version=1复制到另一个文件夹urn:adsk.wipprod:fs.folder:co.0xaYa2rVTJuFiz7rxLCOQQ So, the API call will look like the following:因此,API 调用将如下所示:

Note.笔记。 The URL safe form of the version id is urn%3Aadsk.wipprod%3Afs.file%3Avf.rH_L4XJsTmeiYA4ixCVNAA%3Fversion%3D1版本 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
            }
      }
   ]
}

Hope it helps!希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM