【发布时间】:2020-06-30 07:19:10
【问题描述】:
这是我的文件夹在谷歌驱动器中的结构:
Picture
|----------Date1
|-----Pic1.png
|-----Pic2.png
|----------Date2
|-----Pic3.png
|-----Pic4.png
现在我只有图片文件夹(parentID 文件夹)的 ID。现在我想获取 Pic1 图片(在 Date1 文件夹内)。是否可以只查询 1 次以获取只有图片文件夹 ID 的图片,或者我必须多次查询(获取 Date1 和 Date2 文件夹 ID,然后继续查询)?
这是我现在的代码
$imageName= "Pic1" // name of the image I want to find, which is Pic1
$folderId = "PictureFolderId" // Folder Picture's ID
$optParams = array(
'pageSize' => 1,
'fields' => 'nextPageToken, files(contentHints/thumbnail,fileExtension,id,name,size)',
'q' =>"mimeType contains 'image/' AND name contains '".$imageName."' AND '".$folderId."' in parents"
);
$results = $googleDriveService->files->listFiles($optParams);
if (count($results->getFiles()) == 0) {
print "No files found.\n";
} else {
// Do something.
}
【问题讨论】:
-
你有图片的名字和它的父ID吗?请编辑您的问题并包含您的代码。
-
是的。我在下面添加了我目前拥有的代码。
-
try 'fields' => '*',它会将完整的文件对象返回给你。
标签: google-api google-drive-api parent-child