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 /wf/restapi/v2/AssetsByPath 34 * 35 * Parameters: 36 * paths=["asset/data/path1.txt","asset/data/path2.txt"] 37 * verbose=true 38 * 39 * Response: 40 [ 41 { 42 "id": 201629307, 43 "name": "path1.txt", 44 "path": "asset/data/path1.txt", 45 "height": 0, 46 "width": 0, 47 "bytes": 0, 48 "lastModified": 1507845948000, 49 "mimeType": "text/plain", 50 "previews": { 51 "thumbnail": "../servlet/jb.view?table=thumbnails&col=thumbnails&id=pe_323031363239333037", 52 "viewex": "../servlet/jb.view?table=viewex&col=viewex&id=pe_323031363239333037", 53 "downloadUrl": "../servlet/dload?id=pe_323031363239333037" 54 } 55 }, 56 { 57 "id": 201629308, 58 "name": "path2.txt", 59 "path": "asset/data/path2.txt", 60 "height": 0, 61 "width": 0, 62 "bytes": 0, 63 "lastModified": 1507845948000, 64 "mimeType": "text/plain", 65 "previews": { 66 "thumbnail": "../servlet/jb.view?table=thumbnails&col=thumbnails&id=pe_323031363239333038", 67 "viewex": "../servlet/jb.view?table=viewex&col=viewex&id=pe_323031363239333038", 68 "downloadUrl": "../servlet/dload?id=pe_323031363239333038" 69 } 70 } 71 ] 72 */ 73 function main() { 74 REST.setCallback(pathToAssetInfo); 75 return REST.execute("paths"); 76 } 77 main(); 78