Objective c 如何上传文件到谷歌驱动器只有当它不存在?

Objective c 如何上传文件到谷歌驱动器只有当它不存在?,objective-c,ios7,google-drive-api,Objective C,Ios7,Google Drive Api,我使用xcode开发iphone应用程序 我上传数据库文件到我的谷歌驱动器与此代码 - (void)uploadDB{ GTLDriveFile *file = [GTLDriveFile object]; file.title = [NSString stringWithFormat:@"User:%@DB.sqlite",UserName]; file.descriptionProperty = @"Uploaded from iOS "; file.mi

我使用xcode开发iphone应用程序

我上传数据库文件到我的谷歌驱动器与此代码

- (void)uploadDB{
    GTLDriveFile *file = [GTLDriveFile object];
    file.title = [NSString  stringWithFormat:@"User:%@DB.sqlite",UserName];
    file.descriptionProperty = @"Uploaded from  iOS ";
    file.mimeType = @"application/x-sqlite3";


    // Attach a DB file to the email

    NSArray *paths = NSSearchPathForDirectoriesInDomains
    (NSDocumentDirectory, NSUserDomainMask, YES);

    NSString *documentsDirectory = [paths objectAtIndex:0];

    //make a file name to write the data to using the documents directory:
    NSString *fileName = [NSString stringWithFormat:@"%@/%@",
                          documentsDirectory,DB_File];
    NSData   *data = [NSData dataWithContentsOfFile:fileName];


    GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithData:data MIMEType:file.mimeType];
    GTLQueryDrive *query = [GTLQueryDrive queryForFilesInsertWithObject:file
                                                       uploadParameters:uploadParameters];

    UIAlertView *waitIndicator = [self showWaitIndicator:@"Uploading to Google Drive"];

    [self.driveService executeQuery:query
                  completionHandler:^(GTLServiceTicket *ticket,
                                      GTLDriveFile *insertedFile, NSError *error) {
                      [waitIndicator dismissWithClickedButtonIndex:0 animated:YES];
                      if (error == nil)
                      {
                          NSLog(@"File ID: %@", insertedFile.identifier);
                          [self showAlert:@"Google Drive" message:@"File saved!"];
                      }
                      else
                      {
                          NSLog(@"An error occurred: %@", error);
                          [self showAlert:@"Google Drive" message:@"Sorry, an error occurred!"];
                      }
                  }];

}
我的问题是,它总是保存为一个新的文件,我希望它会检查,如果这个文件名存在于驱动器上,并替换它


谢谢

驱动器中文件的标题不是唯一的。相反,您应该使用资源id。第一次上载数据库文件时,请记住它在成功时返回给您的资源id,然后从那时起进行更新。

I使用此SDk新建,如何获取资源id?如何检查位于驱动器上的文件的资源id?如何检查位于驱动器上的文件的资源id?