0

how long does I get urn in my code on derivativesApi

Autodesk.Forge.Model.DynamicJsonResponse translateResponse = derivativesApi.Translate(job, true); string responseUrn = translateResponse.Dictionary["urn"].ToString();

noja
  • 82
  • 9

1 Answers1

0

I guess you're asking the string length of the base64 urn.

It depends on the characters of the objectId (a.k.a object urn returned by PUT /buckets/:bucketKey/objects/:objectName) you passed into the base64 string encoder with my experience, and it will be the same urn you pass to the POST job of the Forge Model Derivative API. Normally, each Base64 digit represents exactly 6 bits of data from the wiki and here is a formula to calculate the encoded string length link:

((4 * n / 3) + 3) & ~3

note1. n is the string length of your objectId.

For instance, the length of the urn:adsk.objects:os.object:mybucket/example.txt is 47. After base64 encoding, the result dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bXlidWNrZXQvZXhhbXBsZS50eHQ= length is ((4 * 47 / 3) + 3) & ~3 = 64.

note2. The padding character = must be removed while triggering Forge translation jobs manually, Forge Model Derivative API doesn't allow it. Here is the formula:

len of the urn = 64 - n of the padding character `=`

Therefore, the final string length of the urn you obtain from the API response is 64 - 1 = 63.

Ref. https://en.wikipedia.org/wiki/Base64

note3. Unless you call DELETE :urn/manifest to deleted the translated results (a.k.a.viewable bubbles), viewable bubbles will be stored in Forge server permanently. You can also use viewable bubbles' urn to access them, despite the model file stored in your managed OSS bucket is deleted by the bucket policy you have set up.

Eason Kang
  • 6,155
  • 1
  • 7
  • 24
  • I ask the available time of the urn code generated in autodesk viewer(derivativesApi) – noja Jan 11 '19 at 07:17
  • Hi, I think the note3 converted the lifetime of the URN. – Eason Kang Jan 11 '19 at 07:20
  • I ask this question for the api that autodesk offers – noja Jan 11 '19 at 07:28
  • My bad, if you're asking what is the timing you can obtain the URN, here is my answer. Once you uploaded your model to Forge server via Data Management API https://forge.autodesk.com/en/docs/data/v2/reference/http/buckets-:bucketKey-objects-:objectName-PUT/, it will returns `objectId`, a.k.a the `urn`. Before submitting a translation job, you have to convert this `urn` into `based64 urn`, . After doing this, you got the `urn` you request immediately. It's the same as the one you asking `translateResponse.Dictionary["urn"].ToString();`. – Eason Kang Jan 11 '19 at 07:54
  • The link is `PUT /buckets/:bucketKey/objects/:objectName` mentioned above, https://forge.autodesk.com/en/docs/data/v2/reference/http/buckets-:bucketKey-objects-:objectName-PUT/ . However, I edited it, it should be a good link. – Eason Kang Jan 11 '19 at 07:58
  • I want to know how long I can use this urn code. The urn code I produced 1 time lived 4 days. How many days will live? – noja Jan 11 '19 at 08:00
  • As I mentioned, the urn is just a link to the viewable bubbles. It will live until you call DELETE :urn/manifest to remove it from Forge server. Could you tell more about this `The urn code I produced 1 time lived 4 days`?? – Eason Kang Jan 11 '19 at 08:02
  • can I use the code unless I delete it? the main answer to this problem – noja Jan 11 '19 at 08:25