I am struggling to find the right folder in Google Drive. I am using import 'package:googleapis/drive/v3.dart'
Folder Structure
--FolderA
|
|--FolderC // Note this sub folder has the same name as one of the other folders
--FolderB
--FolderC
var query = "mimeType='application/vnd.google-apps.folder' ";
query += "and name='$folderName'"; // folderName = "FolderC"
....
...
Future<List<File>> _runQuery(String query) async {
DriveApi driveApi = DriveApi(await getHttpClient());
return (await driveApi.files.list(q: query)).files;
}
...with the above code I can see the folders with their id, name, etc.
. The problem is the parents
for all the folders are null
. Because of this I coudn't find out which 'FolderC' is which.
So, is there a way to find out a subfolder of a specific folder?
Update 1:
If I add parents in the query, I am getting an empty list (no folders at all)
var query = "mimeType='application/vnd.google-apps.folder' ";
query += "and name='$folderName' "; // folderName = "FolderC"
query += "and '${parentFolder.id}' in parents";
In your case, how about modifying the search query?
"mimeType='application/vnd.google-apps.folder' and name='$folderName' and '### folder ID of FolderA ###' in parents"
FolderC
in the folder FolderA
is retrieved.parents
in fields
for request. Or you can also use *
as the fields. In this case, all metadata can be retrieved.If I misunderstood your question and this was not the result you want, I apologize.