Status Update
Comments
du...@google.com <du...@google.com>
du...@google.com <du...@google.com> #2
Hi,
I wasn't able to reproduce your issue, i'm getting all the images for each folder. Are the images directly in the folders you're querying for? The 'parents' query term doesn't support nested sub-folders, it only has the ID of the direct parent folder containing the file [1].
[1]
ca...@gmail.com <ca...@gmail.com> #3
Are the images directly in the folders you're querying for?
Yes they are. Take the first query I supplied for example:
It trying to get files within
The 'parents' query term doesn't support nested sub-folders, it only has the ID of the direct parent folder containing the file
I was disappointed to hear about this, and I hoped there was another method that would allow you to query for nested subfolders, but there wasn't so I coded my own method to conduct such a query. However, as I've explained in the main post, and now in this reply, the two folders in this example are in fact direct parent folders containing a list of files that are images. However, as you can see in the query's response as I linked, it only returns one file.
I truly don't think I am misusing the Google Drive API, I'm absolutely certain I should be receiving a list of images in this respective example, and the respective results in the other queries I mentioned in my main post.
ja...@google.com <ja...@google.com> #4
Hello,
This issue has been reported to the relevant team.
Cheers!
ca...@gmail.com <ca...@gmail.com> #5
Thank you very much. If there any any updates, questions, etc. please keep me up to date.
du...@google.com <du...@google.com>
ni...@gmail.com <ni...@gmail.com> #6
This looks like it is the same issue that I've had reported to me in rclone.
I made a demo of the problem with the API explorer
If you try this query for two publicly accessible directories
(('1nJBJzllQF63jA2kMPwkwtCTUV7PD_tkR' in parents) or ('1yIWAJcjkUOhppRy2Tppw1wFO-nqEDFX7' in parents))
You get
{
"kind": "drive#fileList",
"incompleteSearch": false,
"files": []
}
However if you try ('1nJBJzllQF63jA2kMPwkwtCTUV7PD_tkR' in parents)
on its own you get the directory listing as you do if you try ('1yIWAJcjkUOhppRy2Tppw1wFO-nqEDFX7' in parents)
and
In summary
listing with
- A in parents - OK
- B in parents - OK
- (A in parents) or (B in parents) - FAIL
Note that this does work nearly all the time, just not for some combination of shared folders that I haven't worked out yet - that is why I've linked to specific public folders to try!
ca...@gmail.com <ca...@gmail.com> #7
Though it's unfortunate to say, I'm glad someone else is having this issue in order to bring light to it. It's been a few months now and there is still no update either.
bt...@int-color.com <bt...@int-color.com> #8
ca...@gmail.com <ca...@gmail.com> #9
Node as in nodejs environment? If so, I believe you are incorrect in saying the issue is with the Google package for nodejs. The reason is for both the situation post #6 describes, as well as my original post. By using Google's very own API explorer, the inconsistencies still continue in the results, and I assume they too aren't using the Google package in their backend for the API explorer.
ja...@google.com <ja...@google.com>
ja...@google.com <ja...@google.com> #10
Hello, sorry for the late reply.
This behavior of the API is intended. In the V3 Drive API, when performing a query with a single parent folder, the behavior is similar to the V2 Drive API Children
ni...@gmail.com <ni...@gmail.com> #11
Thanks for the info
Can you explain further exactly what you mean by "In brief, multi-parent queries don't search the same corpus of files as single queries ones, so the results are different."?
In my example in #6 (which you can try) I don't think the directories are in different corpora are they?
It would be super useful in this case if it returned incompleteSearch = true
(it doesn't at the moment) so we have to guess whether the search worked or not.
Aside: Would it be possible to implement an ID in anyparents
query which searches for items which have an eventual ancestor ID
? That is what these multi parent searches are doing - attempting to work around a weakness in the API which in order to read a directory tree starting from a given directory it is necessary to query each directory individually. This can be sped up by querying multiple directories at once.
an...@gmail.com <an...@gmail.com> #12
Hi,
Is there any possibility of getting either of the above suggestions implemented?
Otherwise, it takes a long time to iterate over directories container 100s of 1000s of files & folders 1 at a time.
Thanks.
VF...@lacity.org <VF...@lacity.org> #13
jm...@gmail.com <jm...@gmail.com> #14
nh...@gmail.com <nh...@gmail.com> #15
tk...@gmail.com <tk...@gmail.com> #16
Then, you concatenate the parent ids with eg:
if (folderIds.length > 0) {
params.q = `${params.q} and ('${folderIds.join(
"' in parents or '",
)}' in parents)`;
}
The result will be a big-ass string but it should work. Probably in cases it might yield 431 due to too long search parameters but so far so good.
If there's somebody working on this, an array would be a bit nicer and shorter to use eg ["id1", "id2"] in parents
mi...@gmail.com <mi...@gmail.com> #17
when adding "corpora", "supportsAllDrives" and "includeItemsFromAllDrives"
parameters it solved my problem
Not sure if it fixes yours
const payload =
{
'corpora':"allDrives",
'supportsAllDrives': true,
'includeItemsFromAllDrives': true,
'q': `'${folder}' in parents or '${folder2}' in parents `,
};
return Drive.Files.list(payload)
Description
A short description of the issue:
What API version are you using (v2, v3, Android)? v3
A small code sample that reliably reproduces the issue. The sample should run as-is or with minimal setup, without external dependencies.
[Folder of images] or [Folder of images]
[Folder of images] or [Folder of folder (x1) and images]
[Folder of folder (x1) and images] or [Folder of folder (x1) and images]
[Folder of images] or [Folder of only folders]
[Folder of folder (x1) and images] or [Folder of only folders]
Additionally, I have attached a text file that is poorly organized, which contains a little more detail about the folders and their ids, along with the same queries I posted above. For what it's worth, I have tried this using the 'Try this API', 'Google Developers OAuth 2.0 Playground' (
const res = await this.drive.files.list({
q: `'${folderId1}' in parents or '${folderId2}' in parents`
});
What steps will reproduce the problem?
1. Run one of the following queries above that I have provided that directs you to Google Drive API v3 'Try this API' page.
or
1. Do a GET request for /drive/api/v3/files/list with the query payload containing two or more queries of '<folder-id>' contains ie. '<folder-id-1>' in parents or '<folder-id-2>' in parents or...
What is the expected output? What do you see instead? If you see error messages, please provide them.
=== SCENARIOS I WROTE UP THAT RESULTED FROM THE QUERIES ABOVE, AND IN THE ATTACHED FILE ===
Folder contents
- Folder A: Only images
- Folder B: Only images
- Folder C: 1 folder, and the rest images
- Folder D: 1 folder, and the rest images
- Folder E: 7 folders, nothing else
### Query 1: `'A' in parents or 'B' in parents`
The following query of two folders, both **only containing images** returned** a list that contained only one item, **the first image in folder 'A'**. The result was not intended, expecting all files found in 'A' or in 'B'. What was missing was the rest of the images found in 'A' and all the images found in 'B'.
### Query 2: `'B' in parents or 'A' in parents`
The following is identical to Query 1 except that the ordering of the query is swapped. The result is the same, **returning the first image in folder 'A'**. The result was not intended, expecting all files found in 'B' or in 'A'. What was missing was the rest of the images found in 'A' and all the images found in 'B'.
### Query 3: `'A' in parents or 'C' in parents`
The following is a query of two folders, one containing only images, and the other containing one folder and the rest as images. The result of `files` was one image and one folder. The result was not intended, expecting all files found in 'A' or in 'C'. What was missing was the rest of the images found in 'A' and all the images in 'C'.
### Query 4: `'C' in parents or 'D' in parents`
The following is a query of two folders, both containing only one folder and the rest of the files as images. The result of `files` was the two respective folders contained within each of the queried folders. The result was not intended, expecting all files found in 'C' or in 'D'. What was missing was all the images found in either 'C' or 'D'.
### Query 5: `'A' in parents or 'E' in parents`
The following is a query of two folders, one containing only images, and the other containing only 7 folders. The result of `files` was one image and 7 folders. The result was not intended, expecting all images found in 'A' and all folders in 'E'. What was missing was the rest of the images found in `A`.
### Query 6: `'C' in parents or 'E' in parents`
The following is a query of two folders, one containing one folder and the rest as images, and the other containing only 7 folders. The result of `files` was 8 folders. The result was not intended, expecting all images and the single folder in `C` and all folders in `E`. What was missing was all the images found in `C`.
---
The following results of the queries above is leading me on to believe that `google.drive.list` is behaving as such:
- Both folders contain only images
- **result** has one image
- **expected** all images
- One folder has only images, the other folder has a folder and images
- **result** has one image and one folder
- **expected** all images and one folder
- Both folders has a folder and images
- **result** has two folders and no other images
- **expected** all images and two folders
- One folder has only images, the other folder has only folders
- **result** has one image and all folders
- **expected** all images and all folders
- One folder has a folder and images, the other has only folders
- **result** has 8 folders
- **expected** all images alongside the 8 folders
Please provide any additional information below.
I do hope you bother to take a look at a reply I made on an issue on GitHub that resulted from my post on StackOverflow. I say this because of the markdown allowed on GitHub that makes everything a little more easier to digest.