question

jsourcen avatar image
jsourcen asked

How to sort to get folders first and files next ?

Am trying to get all children of a folder by this following URL where $id is folder id. Am getting all my folder contents but not in the way i want. I want fitst all folders to come on top and then files to come... $url = $this->meta_url."/nodes/".$id."/children?limit=200"; How do i get this ["property1 ASC","property2 DESC", "property3"] type of sorting param in my URL to get the result sorted in the way where i get all folders followed by files... ?
amazon drive
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jamie Grossman avatar image
Jamie Grossman answered
Hi there, Thanks for posting. I'd suggest checking our some of our documentation, specifically the filtering section found here: https://developer.amazon.com/public/apis/experience/cloud-drive/content/nodes#Filtering Please keep in mind that this kind of request may require two calls; one to fetch the folders in a specific order, and another to fetch the actual files in a specific order. Hope this helps! Jamie
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jsourcen avatar image
jsourcen answered
Okay. I was actually getting all (folders and files) of a specific folder with this request... $url = $this->meta_url."nodes/".$id."/children?asset=ALL&tempLink=true"; So i thought i may be able to sort this itself to get folders first and then files...! Anyways thank you for clearing my doubt that i need to make it in 2 queries to get it :)
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

smping avatar image
smping answered
I do this with ?sort=["kind DESC"] but it only works because the kind values are FOLDER and FILE, if they introduce something else it might get a bit weird
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jsourcen avatar image
jsourcen answered
Nope. This does not works for me sir...
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.