Reputation: 3903
Does anyone know if it is possible to get all the bucket files data in some kind of array or similiar? I'm thinking of building a viewer where you can load a different view, containing a different model, when the user clicks on the desired model (thumbnail)
Upvotes: 0
Views: 612
Reputation: 2024
Yes if I do not misunderstand your requirement. You can get all your buckets by GET buckets API, you will get an bucket array like this:
{
"items": [
{
"bucketKey": "mybucket1",
"createdDate": 1508056179005,
"policyKey": "persistent"
},
{
"bucketKey": "mybucket2",
"createdDate": 1502411682779,
"policyKey": "transient"
},
{
"bucketKey": "mybucket3",
"createdDate": 1502420840319,
"policyKey": "transient"
}
]
}
Then, you can iterate all these buckets to get all the files under each bucket by GET buckets/:bucketKey/objects API, it will provide you an array of items like this:
{
"items": [
{
"bucketKey": "mybucket1",
"objectKey": "mytestbim1.rvt",
"objectId": "urn:adsk.objects:os.object:mybucket1/mytestbim1.rvt",
"sha1": "248205b7609ca95c04e4d60fee2ad7b6bd9a2uy2",
"size": 17113088,
"location": "https://developer.api.autodesk.com/oss/v2/buckets/mybucket1/objects/mytestbim1.rvt"
},
{
"bucketKey": "mybucket1",
"objectKey": "mytestbim2.rvt",
"objectId": "urn:adsk.objects:os.object:mybucket1/mytestbim2.rvt",
"sha1": "248205b7609ca95c04e4d60fee2ad7b6bd8a2322",
"size": 17113088,
"location": "https://developer.api.autodesk.com/oss/v2/buckets/mybucket1/objects/mytestbim2.rvt"
}
]
}
The most important value is the "objectId", it will be the urn after base64 encoded, you can get all the derivative with this urn, and also you can load the urn in Forge Viewer after it's translated to SVF.
We have an code example of Forge Node.js Boilers, and you can check the project 5 to see if that is something you are interested.
Hope it helps.
Upvotes: 1