Autodesk Forge:下载清单附件
Posted
技术标签:
【中文标题】Autodesk Forge:下载清单附件【英文标题】:Autodesk Forge: Download checklist attachment 【发布时间】:2019-09-19 12:21:23 【问题描述】:当我检索一个清单实例时,我得到了以下与附件相关的部分。
"type": "instance_item_attachments",
"id": "5a0a2acf-b02a-4b88-86cc-962c3831bdee",
"attributes":
"name": "6856ad10-6ab0-11e9-9150-9fda3da0626e.png",
"attachmentType": "OSS",
"mimeType": "image/png",
"uploadStatus": "COMPLETED",
"urns": [
"urn": "urn:adsk.wipprod:fs.file:vf.gy4mB910SneymU86Gc4O0A?version=1",
"type": "WIP"
,
"urn": "urn:adsk.objects:os.object:wip.dm.prod/ede3de59-1b68-485c-82fe-f1f2af3442fe.png",
"type": "OSS"
,
"urn": "urn:adsk.checklists.cs.attachment:58b8afcf-d7cd-49ad-aa10-78c50610761b/5a0a2acf-b02a-4b88-86cc-962c3831bdee",
"type": "CHECKLIST"
],
"createdAt": "2019-04-29T18:55:51.334Z",
"updatedAt": "2019-04-29T18:55:54.137Z",
"createdBy": "TAKCJQU6HGXW",
"modifiedBy": "TAKCJQU6HGXW",
"permittedActions": [
"canArchive",
"canEdit"
],
"permittedAttributes": [
"mimeType",
"uploadStatus"
]
,
"links":
"self": "/containers/58b8afcf-d7cd-49ad-aa10-78c50610761b/instance_item_attachments/5a0a2acf-b02a-4b88-86cc-962c3831bdee"
,
"relationships":
"container":
"meta":
"relation": "primary",
"readOnly": false
,
"links":
"self": "/containers/58b8afcf-d7cd-49ad-aa10-78c50610761b/instance_item_attachments/5a0a2acf-b02a-4b88-86cc-962c3831bdee/relationships/container",
"related": "/containers/58b8afcf-d7cd-49ad-aa10-78c50610761b/instance_item_attachments/5a0a2acf-b02a-4b88-86cc-962c3831bdee/container"
,
"data":
"type": "containers",
"id": "58b8afcf-d7cd-49ad-aa10-78c50610761b"
,
"item":
"meta":
"relation": "primary",
"readOnly": false
,
"links":
"self": "/containers/58b8afcf-d7cd-49ad-aa10-78c50610761b/instance_item_attachments/5a0a2acf-b02a-4b88-86cc-962c3831bdee/relationships/item",
"related": "/containers/58b8afcf-d7cd-49ad-aa10-78c50610761b/instance_item_attachments/5a0a2acf-b02a-4b88-86cc-962c3831bdee/item"
,
"data": null
现在,我要下载这个附件,提供的URN是:wip.dm.prod/ede3de59-1b68-485c-82fe-f1f2af3442fe.png
如果我尝试使用以下链接访问它,它会显示未找到
developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/b30e3ffe-333b-446c-b834-e2f2141096b4.png
但是,如果我稍微更改一下 URL(通过添加对象),它就可以正常工作。
developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/b30e3ffe-333b-446c-b834-e2f2141096b4.png
我在这里做错了吗?或者这是提供的骨灰盒中的错误?
【问题讨论】:
【参考方案1】:添加到Adam Nagy reply,您需要破坏 URN。从你原来的问题:
urn:adsk.objects:os.object:wip.dm.prod/ede3de59-1b68-485c-82fe-f1f2af3442fe.png
在 .NET 中,您可以尝试(使用 System.Linq):
string bucketKey = urn.Split("/").First().Split(":").Last();
string objectName = urn.Split("/").Last();
然后重建为:
string attachemtnUrl = string.Format("0/oss/v2/buckets/1/objects/2", BASE_URL, bucketKey, objectName);
您还需要带有有效访问令牌的 Authorization
标头。
【讨论】:
【参考方案2】:OSS(对象存储服务)中对象的id / urn包含bucket name和object name 在“urn:adsk.objects:os.object:”部分之后。
有下载文件的教程https://forge.autodesk.com/en/docs/data/v2/tutorials/download-file/
表示关于item的回复包含storage下下载链接的id和实际的URL 部分:
"storage":
"data":
"type": "objects",
"id": "urn:adsk.objects:os.object:wip.dm.prod/977d69b1-43e7-40fa-8ece-6ec4602892f3.rvt"
,
"meta":
"link":
"href": "https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/977d69b1-43e7-40fa-8ece-6ec4602892f3.rvt"
您可以在此处看到 id 和可用于下载文件的 URL 之间的连接
【讨论】:
Checklist 提供以下 URN:urn:adsk.objects:os.object:wip.dm.prod/ede3de59-1b68-485c-82fe-f1f2af3442fe.png 如果我尝试使用以下 URL 获取 GetItem,它说找不到developer.api.autodesk.com/data/v1/projects/… 如果我理解正确,在我的情况下,我必须从 urn 中提取存储桶密钥和对象名称并使用以下 API 调用 forge.autodesk.com/en/docs/data/v2/reference/http/… 我可以这样做,但我希望清单提供一个商品编号 对于属于 BIM 360 Docs(或 A360、Fusion Team 等)文件系统的文件,您只有一个“项目”,如此处所示 forge.autodesk.com/blog/ids-data-management-api - 即如果您能找到该文件通过迭代您的集线器/项目/文件夹 清单附件未列为项目。我希望这不是一个大问题,我们可以提供下载清单附件的示例代码吗?谢谢。以上是关于Autodesk Forge:下载清单附件的主要内容,如果未能解决你的问题,请参考以下文章
如何为 Autodesk Forge API 问题创建照片附件?