Reputation: 25
Google specifies the metadata in https://developers.google.com/drive/api/v3/reference/files#resource.
If I do
$parameters['fields']="*";
$files = $service->files->listFiles($parameters);
Then I indeed get pretty much all that. If I just do
$files = $service->files->listFiles($parameters);
i.e. no fields setting I get a subset, but some fields such as createdTime are now blank - and that is one I need. Google recommend (https://developers.google.com/drive/api/v3/fields-parameter) listing only the fields you need to improve performance, but just about everything I put in fields gets an error "Invalid field selection" (tested in https://developers.google.com/drive/api/v3/reference/about/get?apix_params=%7B%22fields%22%3A%22createdTime%22%7D)
$parameters['fields']="name,parents,mimeType,filesize,createdTime,modifiedTime";
$files = $service->files->listFiles($parameters);
Any clues as to how this works? Thanks
Upvotes: 1
Views: 620
Reputation: 201553
I believe your goal as follows.
name,parents,mimeType,filesize,createdTime,modifiedTime
using Drive API v3 with googleapis for php.filesize
. In this case, it's size
.name,parents,mimeType,size,createdTime,modifiedTime
are set for the method of "Files: list" of Drive API v3, please use files(name,parents,mimeType,size,createdTime,modifiedTime)
. I think that the reason of your error message of Invalid field selection name
is due to this.When above points are reflected to your script, it becomes as follows.
$parameters['fields']="name,parents,mimeType,filesize,createdTime,modifiedTime";
To:
$parameters['fields']="files(name,parents,mimeType,size,createdTime,modifiedTime)";
Upvotes: 2