I would ask in the Objective-C client library group: http://groups.google.com/group/gdata-objectivec-client <http://groups.google.com/group/gdata-objectivec-client> Eric
On Sun, May 24, 2009 at 10:52 PM, aaronjang <[email protected]> wrote: > > I Have been use this code success batch upload docs but no > content,only title: > #pragma mark batch add events > -(GDataEntryDocBase *)CreateDECE:(NSDictionary *)info > { > GDataEntryDocBase *newEntry ;//= [[[GDataEntryDocBase alloc] init] > autorelease]; > > // set a title and description (the author is the authenticated user > adding > // the entry) > > NSString *mimeType = nil; > Class entryClass = nil; > > [self getMIMEType:&mimeType andEntryClass:&entryClass > forExtension:@"txt"]; > if (mimeType && entryClass) { > > newEntry = [entryClass documentEntry]; > NSString *title = [info objectForKey:@"title"]; > > [newEntry setTitleWithString:title]; > > NSData *data = [info objectForKey:@"data"]; > if(data) > { > [newEntry setUploadData:data]; > [newEntry setUploadMIMEType:mimeType]; > [newEntry setUploadSlug:title]; > [newEntry setSummaryWithString:title]; > > } > } > return [newEntry retain]; > } > > - (BOOL)uploadDatas:(NSArray *)datas { > > NSURL *batchURL = [[mDocListFeed batchLink] URL]; > > const int kMaxBatchSize = 100; > > if(batchURL == nil) return NO; > NSMutableArray *batchTickets = [NSMutableArray array]; > NSMutableArray *batchResults = [NSMutableArray array]; > > unsigned int totalEntries = [datas count]; > unsigned int idx=0; > NSMutableArray *contacts=[NSMutableArray array]; > > // make a new entry for the file > for (idx = 0; idx < totalEntries; idx++) { > > NSDictionary *info=[datas objectAtIndex:idx]; > > GDataEntryBase *entry = [self CreateDECE:info]; > // add a batch ID to this entry > static int staticID = 0; > if(entry != nil) > { > NSString *batchID = [NSString stringWithFormat:@"%u", > ++staticID]; > [entry setBatchIDWithString:batchID]; > > GDataBatchOperation *op = [GDataBatchOperation > batchOperationWithType:kGDataBatchOperationInsert]; > [entry setBatchOperation:op]; > [contacts addObject:entry]; > } > if (((idx + 1) % kMaxBatchSize) == 0 || (idx + 1) == > totalEntries) > { > unsigned int rangeStart = idx - (idx % > kMaxBatchSize); > NSRange batchEntryRange = NSMakeRange(rangeStart, > idx - rangeStart > + 1); > NSArray *entrySubset = [contacts > subarrayWithRange:batchEntryRange]; > NSLog(@"entrySubSet:%@",entrySubset); > > GDataFeedDocList *feed = [[[GDataFeedDocList alloc] > init] > autorelease]; > [feed setNamespaces:[GDataEntryDocBase > baseDocumentNamespaces]]; > > [mDocListFeed setNamespaces:[GDataEntryDocBase > baseDocumentNamespaces]]; > > GDataFeedDocList *batchFeed = feed; > > > [batchFeed setEntriesWithEntries:entrySubset]; // > > GDataServiceGoogleDocs *service = [self > docsService]; > GDataServiceTicket *ticket; > > ticket=[service > fetchDocsBatchFeedWithBatchFeed:batchFeed > > forBatchFeedURL:batchURL > > delegate:self > > didFinishSelector:@selector > (uploadDatasTicket:addedEntry:) > > didFailSelector:@selector > (uploadDatasTicket:failedWithError:)]; > > [batchTickets addObject:ticket]; > > // set the arrays used by the callback into the > ticket properties > [ticket setProperty:batchTickets forKey:@ > "BatchTickets"]; > [ticket setProperty:batchResults forKey:@ > "BatchResults"]; > > > } > > } > > return YES; > } > > > Client: > NSData *data = [testData dataUsingEncoding:NSUTF8StringEncoding]; > NSDictionary *dict = [NSDictionary > dictionaryWithObjectsAndKeys:@"Hello",@"title",data,@"data",nil]; > NSArray *arry = [NSArray arrayWithObject:dict]; > > [[DocsAgent sharedDocsAgent] uploadDatas:arry]; > > Only show "Hello" title in docs list without content.pls help... > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Data Protocol" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-help-dataapi?hl=en -~----------~----~----~----~------~----~------~--~---
