I have a Google Drive that is conveniently organized and has sub-folders within it's shared drive. I am attempting to parse through all, or specified, folders and retrieve their contents, or images. I have working code for retrieving all folder ids given a root folder id, and I have working code for retrieving files in one folder.
My issue is that when I attempt to string together the query to retrieve files within any of the specified folder ids, the following is returned in the API response: an empty files
array despite there being images in each respective folder, or a files
array containing only folder mime-types and not a single image.
I have been stuck on this issue trying everything from changing my permission scope, different folders, trying to Frankenstein together a query, but nothing as gotten me closer.
Here is an example of my query: '<folder-id-1>' in parents or '<folder-id-2>' in parents
.
And the snippet from my code:
const res = await this.drive.files.list({
q: `(${encodeURIComponent(foldersChunk.map(folder => `'${folder.id}' in parents`).join(' or '))})`
});
Do I have to query each individual folder one-by-one? I was hoping on finding a better solution so I don't have to make excessive API calls to Google or potential slow down the application for the user by having to request each individual folder, as opposed to getting images in multiple folders as once.
FWIW: I have taken a look at this post on S.O. which is where I got the idea in the first place. Another user made a comment about how a similar query, nesting <folder-id> in parents
together, worked for them, but like I explained, it hasn't for me.