I have a folder in my google drive and I want to list its files and subfolders using google drive Api through a search box. Does Api provide any flexibility to get folders.
I've a script to get folders but it's not working properly. Showing some trashed folder. I want files too.
$this->client = $googl->client();
$this->drive = $googl->drive($this->client);
$folderId = '0B4JDg65OBlTM3RseUk';
$parameters = [
'q' => "'$folderId' in parents",
'fields' => 'files(id, name, modifiedTime, iconLink,
webViewLink, webContentLink)'];
$result = $this->drive->files->listFiles($parameters);
To list files, you may use the files.list
method of the API. This method accepts the q
parameter, which is a search query combining one or more search terms.
Response:
{
"kind": "drive#fileList",
"nextPageToken": string,
"incompleteSearch": boolean,
"files": [
files Resource
]
}
Example for files.list
:
Search for the ID
1234567
in theparents
collection. This finds all files and folders located directly in the folder whose ID is1234567
.
'1234567' in parents
To see the valid search parameters, you may visit this link .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.