2

我正在我的 iPhone 应用程序中集成 google drive SDK。我正在尝试使用以下方法将文件上传到文件夹中

-(void)uploadFileAtPath:(NSString *)path atIndexid:(int)indexId{

   GTLDriveFile *parentRefFile=[driveFilesArray objectAtIndex:indexId];
   if ([parentRefFile.mimeType isEqualToString:@"application/vnd.google-apps.folder"]) {

    NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:path];
    NSLog(@"path--str------%@",path);

    if (fileHandle) {
        GTLServiceDrive *service = [self createServiceDriveObj];

        GTLDriveChildReference *childRef=[GTLDriveChildReference object];
        childRef.childLink=path;
        childRef.kind=@"drive#childReference";
        GTLQueryDrive *query = [GTLQueryDrive queryForChildrenInsertWithObject:childRef folderId:parentRefFile.identifier];


        ticket= [service executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
                                                        GTLDriveFile *uploadedFile,
                                                        NSError *error) {
            // Callback
            if (error == nil) {
                [_delegate didFinishUploadingFileAtPath:path ForTheObject:_delegate];

            } else {
                [_delegate didFailedToUploadFileAtPath:path withError:error ForTheObject:_delegate];
            }
        }];

    } else {
        // Could not read file data.
        [self displayAlert:@"No Upload File Found" format:@"Path: %@", path];
    }
}
else {
    [self displayAlert:@"File type you have choosen is not a folder" format:nil];
}

}

当我调用上述方法上传时,我收到以下错误消息 操作无法完成。(需要资源元数据)。我不确定我错过了什么。如果我想设置 GTLChildReference 对象的标识符属性,我不确定为该属性设置什么。请帮助我

4

0 回答 0