You are not logged in.
Pages: 1
How would i go about listing all files in a folder? I can't seem to locate a method for this in the API reference.
Offline
Hi,
You want Files.GetAssetsForParent(...) and possibly also Folders.GetContainersForParent(...)
Ben
Offline
Thanks! Need a little syntax help again if you don't mind.
For Files.GetAssetDetails I have
$details = $myIMSClient->Files_GetAssetDetails(array($file_id, 'options' => array('publishedFiles')));
but it returns a "BAD_INPUT" error
Offline
You probably want:
$details = $myIMSClient->Files_GetAssetDetails(array("assetId" => $file_id, "fields" => array("publishedFiles" => true)));
Ben
Offline
Thank you!
Offline
Sorry to keep bothering you, but if the publishedFiles array is empty, that means the asset has not been published, correct?
Last edited by ajpinto (2017-12-05 13:20:49)
Offline
Hello?
Offline
Hi,
Sorry I missed your last few replies.
The publishedFiles array is populated with information for each "publication" of the asset in question, but only those publications that the current user has access to. i.e. if you can manage all published files, you will see all publications, but if you don't you will only see publications that you have made yourself.
So, the array being empty, is not necessarily an indicator of whether the file has been published, unless the current user can manage all publish files. This permission is controlled by the "Create, edit and delete published files" option in the Downloads section when editing a user.
Best wishes,
Ben
Offline
is using the publishedFiles array the best way to get the URL of the file in question or is there a better method?
Offline
Also, trying to build a drop down box to select a folder. I can get top level folders no problem, but adding recursion to drill down to child folders using 'Folders_GetContainersForParent' has proved to be a challenge. I would like to wrap the child folders into option groups, but I seem to end up with several empty option groups (which i suspect is due to some of the results not being folders), as well as missing folders. Is there a way to exclude results from the array that aren't folders? Do you have an recommendations as to the best method to build what I'm looking for?
Offline
Hi,
re. Folders_GetContainersForParent - this will only return folders. Your empty option groups might be because the parent folders don't contain subfolders. You can check this with the hasChildContainers key in the folder details hash for each folder. If you're still having problems perhaps you could post some code so I can help pinpoint the issue.
There isn't necessarily a right way or wrong way and I'm not entirely sure what your end goal is. All I would say is that it sounds like you're trying to build the entire folder tree into one drop down - this might well be fine if you don't envisage the folder structure being too large, but would be problematic if the structure is deeply nested, or if nodes have many sub-nodes, or both. i.e. you'll potentially have to make many recursive calls to fill the dropdown before you can present anything to your users. An alternative is to only request the sub-containers on demand - e.g. make an Ajax request when a user selects a parent folder from a dropdown, and then dynamically populate another dropdown. There are many many ways of presenting tree structures though, and I have made the assumption you're writing a web based application, so bear this in mind when deciding how to proceed.
Your previous question "is using the publishedFiles array the best way to get the URL of the file in question or is there a better method?" - it's definitely the best way to get the urls of "published" versions of assets within IMS if you already know which asset you're interested in. If you want to list all assets that have been published, filtering out those that haven't, then you probably also want to use the "filterMode":"publishedFiles" in the "options" parameter when getting folder details.
The other thing to mention is that "publishing" is one of two ways of getting URLs to the assets in IMS. Publishing is audited and has a comprehensive user interface when using the IMS web application. Files published in this way have entries in the "publishedFiles" array. But it is also possible to generate "Fetch File URLs" using the API - this is designed much more as a programmatic way of generating URLs and is not audited - i.e. a user (admin or otherwise) can not see whether a Fetch File URL has been generated for a particular file. The two methods are discussed on this page https://www.thirdlight.com/docs/display … on+the+Web and if you wish to pursue the latter option you'll want to look at the API method "Downloads.GetLink" which allows you to create secure urls (i.e. ones which have an authentication token and so can not be tampered with to get different data).
I hope all that helps,
Ben
Offline
Pages: 1