Third Light Developer Exchange

Code and templating community forum for developers and software integrators

You are not logged in.

Announcement

If you wish to join the Developer Exchange, please contact your account manager - this is to avoid unnecessary spam in the forums. Many thanks for your understanding.

#1 2019-08-15 15:36:21

thirdlight
Third Light Staff
Registered: 2013-06-06
Posts: 23

Example to retrieve a permanent URL to a specific file

If you want to get a permanent URL to a file in an IMS v6 site, you will need the API module. You can then access the Downloads.GetLink() method, and use the permanent=true flag.

First, login to get a session:

{ 
   "action":"Core.Login",
   "inParams":{ 
      "username":"ims-username",
      "password":"ims-password",
      "apiVersion":"1.0"
   }
}

Response:

{ 
   "result":{ 
      "api":"OK",
      "action":"OK",
      "timings":{ 
         "initTime":52,
         "setupTime":12,
         "methodTime":635,
         "totalTime":699
      }
   },
   "outParams":{ 
      "sessionId":"-Qqmhm1wvK5QrLIEpByyyujGBgJKh8VX",
      "userDetails":{ 
         "type":1,
         "userref":"123-5132142",
         "username":"ims-username",
         "description":"IMS Service Account",
         "email":"info@example.com",
         "canPublish":true
      }
   }
}

You'll get a session ID back which you need to use when you request the download for a particular asset. Here's an example to get a 300x400 JPEG for asset 1033454336:

{ 
   "sessionId":"-Qqmhm1wvK5QrLIEpByyyujGBgJKh8VX",
   "inParams":{ 
      "assetId":"1033454336",
      "settings":{ 
         "permanent":true,
         "width":300,
         "height":400,
         "format":"jpeg"
      }
   },
   "action":"Downloads.GetLink",
   "apiVersion":"1.0"
}

Response:

{ 
   "result":{ 
      "api":"OK",
      "action":"OK",
      "timings":{ 
         "initTime":62,
         "setupTime":10,
         "methodTime":71,
         "totalTime":143
      }
   }, "outParams":"https:\/\/ims-site.thirdlight.com\/file\/1\/1033454336\/width=300\/height=400\/format=JPEG\/fit=scale\/rev=0\/t=434965\/e=never\/k=604cbcb0\/imgp1129.jpeg"
}

In the outParams, you can now use the URL to the image after decoding it from the JSON. Notice that there is a signature value in the key/value pair k=604cbcb0. This checksum verifies that the URL was generated by Third Light, preventing tampering.

Offline

Board footer