How do I get the folder ID on Google Drive in iOS?

I need to upload a file to a specific folder in Google Drive using the iOS app. I know the name of the folder, but in order to upload it to a specific folder, I also need to specify an identifier for this folder. Here is the part of my code where I hardcoded the identifier for the destination folder. So my questions are: how can I find the destination folder identifier programmatically.

NSString *mimeType = @"image/png"; NSData *imageData = UIImagePNGRepresentation(imageView.image); GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithData:imageData MIMEType:mimeType]; GTLDriveFile *fileObj = [GTLDriveFile object]; fileObj.title = @"this_is_a_test.png"; GTLDriveParentReference *parentRef = [GTLDriveParentReference object]; parentRef.identifier = @"0B1Em3SqS0WHrQi15SHB4OHRGd2c"; fileObj.parents = [NSArray arrayWithObject:parentRef]; 
+4
source share
1 answer

Querying the drive list can be limited by selecting folders using the query string parameter:

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

But file and folder names are not unique to Google Drive, so there may be many folders or files in a user account with the same name.

+3
source

All Articles