0

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)

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Ok yes, thanks for that! :-) Is there a way to base64 encode the ObjectID right away? I mean so that I can put all urn's into an array and pass them to a list of anchors so that I can re-initialize the viewer each time I click on the single anchor?
That depends on which language you are using, for example, with node.js, you can use something like this: > console.log(new Buffer("Hello World").toString('base64')); SGVsbG8gV29ybGQ= > console.log(new Buffer("SGVsbG8gV29ybGQ=", 'base64').toString('ascii')) Hello World there should be different libraries for different language if you search.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.