1 /** 2 * Workflow to return the assetID given the path using a REST call 3 */ 4 var REST = library.REST.REST(); 5 var myData = {}; 6 7 /** 8 * Adds an object containing the assetID of the src asset fo myData 9 * @param theSource assetID 10 */ 11 function pathToAssetId(theSource) { 12 try { 13 var aFile = new ManagedFile(theSource); 14 } catch (err) { 15 REST.submitError(theSource, "The file with the path does not exist"); 16 return; 17 } 18 myData[theSource] = aFile.assetId; 19 } 20 21 /** 22 * Returns assetIDs using asset paths. 23 * @description Locates assets by the list of paths in 'src' and returns their AssetID values. These paths are parsed into a text object keyed by AssetPath from the JSON file in which they are contained, and by default are displayed to the user. 24 * @example 'MBurl'/wf/restapi/1/pathToAssetID?src=["Path"] 25 * @example <a target="_blank" href=http://127.0.0.1:55555/wf/restapi/1/pathToAssetId?src=["Assets/Library/test.jpg"]>http://127.0.0.1:55555/wf/restapi/1/pathToAssetId?src=["Assets/Library/test.jpg"]</a> 26 * @class Returns AssetIDs using asset paths. 27 * @name PathToAssetID 28 * @param src Path/list of paths of files to get assetIDs from. 29 * @returns ( {'AssetPath': "AssetID",...} ) 30 */ 31 function main() { 32 var aParameters = REST.getParametersToIterate("src"); 33 if (myData.error != null) { 34 return REST.formatResponse(); 35 } 36 REST.iterateThroughParameters(aParameters, pathToAssetId); 37 return REST.formatResponse(); 38 } 39 main(); 40