i want download files google-drive. have fetched gtldrivefile objects drive. downloadurl property of these file objects nil.
googling more, got file.exportlinks has download links. coming nil.
i used code fetch files:
- (void)fetchfiles { gtlquerydrive *query = [gtlquerydrive queryforfileslist]; query.maxresults = 10; [self.service executequery:query delegate:self didfinishselector:@selector(displayresultwithticket:finishedwithobject:error:)]; } - (void)displayresultwithticket:(gtlserviceticket *)ticket finishedwithobject:(gtldrivefilelist *)files error:(nserror *)error { if (error == nil) { if (files.items.count > 0) { filearr=files.items; } } } here filearr has files of class gtlfiledrive.
from google-drive developer site, got following code snippet download file using parameter url:
gtmhttpfetcher *fetcher = [self.service.fetcherservice fetcherwithurlstring: urloffile]; [fetcher beginfetchwithcompletionhandler:^(nsdata *data, nserror *error) { if (error == nil) { nslog(@"retrieved file content"); // data } else { nslog(@"an error occurred: %@", error); } }]; i need urloffile complete task.
any appreciated.
when initial auth, need request right scope - otherwise, rights list files, , not download them.
something like.
nsarray *scopes = [nsarray arraywithobjects:kgtlauthscopedrive, nil]; authcontroller = [[gtmoauth2viewcontrollertouch alloc] initwithscope:[scopes componentsjoinedbystring:@" "] clientid:self.clientid clientsecret:self.clientsecret keychainitemname:kkeychainitemname delegate:self finishedselector:@selector(viewcontroller:finishedwithauth:error:)]; you can see in new google drive picker
Comments
Post a Comment