Since the files/list (https://developers.google.com/drive/v2/reference/files/list) is automatically paged, I'm looking for a way to get all files matching a query in several batches (using a while and nextPageToken). I would also like to show progress of that happening, but that requires knowing the total number of files matching that query.
Using this from an android project so the actual call looks like this:
public static String QUERY_VIDEOS = "mimeType='video/mp4'";
FileList list = mService.files().list().setMaxResults(1000).setQ(QUERY_VIDEOS).execute()
Any ideas?
Thanks
Not possible I'm afraid. I would probably counsel against using a batch size of 1000 as you'll be first against the wall when the 501's start.
To speed things up, you might want to investigate this idea. If you have a large number of files to be fetched, you need to page through them sequentially as you are doing. Sooo, let's say you have 12,000 files. Best you can achieve is 12 x 1,000, where each request is say 3s = 36s. As I said, I avoid 1,000 as it's given me 501 internal errors in the past, so if you go with a page size of 100, then it's 120 x 2s = 240s. Not great. However, if you shard the files, you can do this in parallel. Create 10 folders, and share the files amongst the folders. (you could use properties instead of folders if you want it hidden from the user). Now your q= can include the parent. You can now fire off 10 fetches in parallel, each following its own page tokens. Elapsed time is now 24s.