Search folder inside 'appdata' folder

2020-04-14 08:34发布

问题:

Trying to check folder exists in 'appdata' folder before creating one. Hence I do get file.list with following code:

GTLQueryDrive *folderExistsQuery = [GTLQueryDrive queryForFilesList];
folderExistsQuery.q =  [NSString stringWithFormat:@"mimeType='application/vnd.google-apps.folder' and trashed=false  and 'appdata' in parents and title='%@'",folderName];

The result is an error.Strange thing When I remove either 'appdata' in parents or title='%@' options in the query I don't get any error. Someone could you please explain whats going wrong here?

Any modification to solution are also welcome.

Edit
Printing description of error:

Error Domain=com.google.GTLJSONRPCErrorDomain Code=500 "The operation couldn’t be completed. (Internal Error)" UserInfo=0x1030d5c00 {error=Internal Error, NSLocalizedFailureReason=(Internal Error), GTLStructuredError=GTLErrorObject 0x10308d890: {message:"Internal Error" data:[1] code:500}}

回答1:

There is a problem with queries that contain title and parents on drive.appdata and drive.file scope. You can either add drive.readonly.metadata temporarily if we're not breaking your installed apps. The fix has been pushed back, but I'm trying to make sure we're fixing it as soon as possible.

Another similar issue: Error when listing files with query



回答2:

In current version of API to get list of files in application folder spaces property is used:

GTLQueryDrive * query = [GTLQueryDrive queryForFilesList];
query.q = @"mimeType = 'application/vnd.google-apps.folder' and trashed = false";
query.spaces = @"appDataFolder";