1
我試圖上傳簡單的.txt文件作爲測試。它只有4kb。這裏是我的代碼:Stuck上傳(OS X上的Google Drive Objective-C API)
-(IBAction)uploadFile:(id)sender{
if (![self.credentials canAuthorize]) {
GTMOAuth2WindowController *windowController;
windowController = [[[GTMOAuth2WindowController alloc] initWithScope:scope clientID:kClientID clientSecret:kClientSecret keychainItemName:kKeychainItemName resourceBundle:nil] autorelease];
[windowController signInSheetModalForWindow:self.window
delegate:self
finishedSelector:@selector(windowController:finishedWithAuth:error:)];
}else{
NSLog(@"Credentials already authorized.");
}
GTLDriveFile *driveFile = [GTLDriveFile object];
driveFile.title = @"myfile";
driveFile.descriptionProperty = @"Uploaded by Google Drive API test.";
driveFile.mimeType = @"text/plain";
NSData *data = [[NSFileManager defaultManager] contentsAtPath:@"/Users/Blake/Downloads/glm/util/autoexp.txt"];
GTLUploadParameters *params = [GTLUploadParameters uploadParametersWithData:data MIMEType:driveFile.mimeType];
GTLQueryDrive *query = [GTLQueryDrive queryForFilesInsertWithObject:driveFile uploadParameters:params];
NSLog(@"Starting Upload to Google Drive");
[self.progressBar setHidden:FALSE];
[self.progressBar startAnimation:sender];
[self.driveService executeQuery:query completionHandler:^(GTLServiceTicket *st, GTLDriveFile *df, NSError *error){
[self.progressBar setHidden:TRUE];
if (error == nil) {
NSLog(@"File upload succeeded");
}else{
NSLog(@"Uh-oh: File upload failed");
}
}];
}
的GTMOAuth2Authentication授權並完成處理程序塊從不執行。
我看着活動監視器,它說我的應用程序在開始時發送了54個數據包。所以我想有些東西正在發送。
我該如何判斷這裏發生了什麼問題,如果塊沒有完成給我一個錯誤?
有人能幫我理解我做錯了什麼嗎?