List request page size being ignored

2020-04-16 03:04发布

问题:

I've been working with the drive SDK for the last few days and previously I was able to request 1000 items on a page using listrequest. Now I'm only getting 100 files no matter how high I set the parameter, but if I set it below 100 it will return whatever number. Did they decide to change the max results overnight or something?

回答1:

I'm facing the same problem so I've been doing some tests and this is what I've found:

  • If I try files.list with fields: "files, nextPageToken", I get 100 files only.
  • If I try files.list with fields: "files(name, id, etc, parents), nextPageToken", I get 460 files.
  • If I try files.list with fields: "files(name, id, etc), nextPageToken" without parents field, I get 1000 files.
  • If I try files.list with fields: "files(parents), nextPageToken", I get 460 files.

So it seems that depends on how many fields you request and also if one of the fields requested is parents field.



回答2:

Ok never mind I figured this out. I was requesting all the metadata of each file, which seems to limit the request to 100. I was able to get 1000 per page by requesting only three fields.

EDIT by pinoyyid: This is not the answer. There is nothing that you can do to guarantee that the page will have exactly pageSize items.



回答3:

You've misunderstood what pagesize does. It is a maximum value, not an absolute value. You should always iterate list results until nextPageToken is null.