Sunday 29 November 2020

How to list all root folder and shares on the Google Drive API v3 while paging and using order by?

I've seen a few questions about this but none cover my scenario.

Basically what I want is to use tokens to do paging and also list all folders and files in the root folder including shared files and folders.

This appears to be working, but once I add orderBy it doesn't work well. It works ok with sorting if I remove or sharedWithMe = true but once I add it it like the shared items aren't sorted.

What am I doing wrong?

This is my code (Kotlin and on Android):

val response =
 gDriveClient.files()
 .list()
 .setSpaces("drive")
 .setCorpora("user")
 .setFields("files(id, name, size, modifiedTime, mimeType, parents, quotaBytesUsed),nextPageToken")
 .setQ("('root' in parents or sharedWithMe = true) and trashed = false")
 .setOrderBy("folder,name")
 .setPageSize(params.loadSize)
 .setPageToken(token)


from How to list all root folder and shares on the Google Drive API v3 while paging and using order by?

No comments:

Post a Comment