1 /** 2 * Workflow to return the assetID given the path using a REST call 3 */ 4 var REST = library.REST.REST(); 5 6 /** 7 * Adds an object containing the assetID of the src asset fo myData 8 * @param theSource assetID 9 */ 10 function pathToAssetInfo(thePath) { 11 try { 12 var aFile = new ManagedFile(REST.getFullPath(thePath)); 13 } catch (err) { 14 REST.pushError( 15 REST.errors.e404, 16 "The file with the path does not exist: " + thePath, 17 REST.errors.e404 18 ); 19 return; 20 } 21 REST.push(aFile); 22 } 23 24 /** 25 * @name AssetsByPath 26 * @class Gets the asset info given their path 27 * @description Given the file paths in "paths", this endpoint returns their asset info. 28 * @param paths an array of files paths. 29 * @param [verbose=false] Setting this to true will collect a variety of default values for each asset. 30 * @param [fields] An array of field id's to collect the values for each asset 31 * @returns [{assetInfo}, ... ] 32 * 33 * @example A published renditions section will be sent in response with preset names and public S3 URLs as keys 34 * and values respectively if a license for renditions is enabled. 35 * /wf/restapi/v2/AssetsByPath 36 * 37 * Parameters: 38 * paths=["asset/data/path1.txt","asset/data/path2.txt"] 39 * verbose=true 40 * 41 * Response: 42 [ 43 { 44 "id": 201629307, 45 "name": "path1.txt", 46 "path": "asset/data/path1.txt", 47 "height": 0, 48 "width": 0, 49 "bytes": 0, 50 "lastModified": 1507845948000, 51 "mimeType": "text/plain", 52 "previews": { 53 "thumbnail": "../servlet/jb.view?table=thumbnails&col=thumbnails&id=pe_323031363239333037", 54 "viewex": "../servlet/jb.view?table=viewex&col=viewex&id=pe_323031363239333037", 55 "downloadUrl": "../servlet/dload?id=pe_323031363239333037" 56 }, 57 "publishedRenditions": { 58 "webPNG": "https://aws-cloud-host-s3Bucket/c1ba4a79-2a82-7823-ab28-5a0a1fa8220a/c1ba4a79-2a82-7823-ab28-5a0a1fa8220a.png", 59 "webJpeg": "https://aws-cloud-host-s3Bucket/9ff45e98-dcc0-7823-9e45-c3be6390d3bf/9ff45e98-dcc0-7823-9e45-c3be6390d3bf.jpeg", 60 "webGif": "https://aws-cloud-host-s3Bucket/11a081b2-53cf-7823-bb08-2a7f75c4ccee/11a081b2-53cf-7823-bb08-2a7f75c4ccee.gif" 61 } 62 }, 63 { 64 "id": 201629308, 65 "name": "path2.txt", 66 "path": "asset/data/path2.txt", 67 "height": 0, 68 "width": 0, 69 "bytes": 0, 70 "lastModified": 1507845948000, 71 "mimeType": "text/plain", 72 "previews": { 73 "thumbnail": "../servlet/jb.view?table=thumbnails&col=thumbnails&id=pe_323031363239333038", 74 "viewex": "../servlet/jb.view?table=viewex&col=viewex&id=pe_323031363239333038", 75 "downloadUrl": "../servlet/dload?id=pe_323031363239333038" 76 } 77 } 78 ] 79 */ 80 function main() { 81 REST.setCallback(pathToAssetInfo); 82 return REST.execute("paths"); 83 } 84 main();