Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Public Url of the Google Drive Files?

I'm trying to get a public url that can be accessed anywhere for streaming. I can get the downloadUrl, but doing the same for exportLinks results in null values. The code for this is below, though I don't know what my problem is.

NSError *error;
NSString *exportURLStr;  
GTLDriveFile *file = [driveFiles objectAtIndex:indexPath.row];
exportURLStr = [NSString stringWithFormat:@"%@",file.exportLinks];  
NSURL *url = [NSURL URLWithString:exportURLStr];
NSString *temp1= [NSString stringWithFormat:@"%@",url];

// NSLog of temp1 is Null
// I tried with file.WebContentLink  but getting 404 Error

This is only a snippet of the code, so if I need to show more, just ask.

like image 895
NextStep Avatar asked Sep 12 '13 09:09

NextStep


1 Answers

From google-api-objectivec-client go to DriveSampleWindowController.m,

check the method called - (void)downloadFormatSelected:(NSMenuItem *)menuItem where its shown cleary how to format the exportLinks.

 NSLog(@"%@",[file.exportLinks JSONValueForKey:@"urtitlekey"]); 

This is what you wanted.Hope it helps.

like image 156
Master Stroke Avatar answered Oct 19 '22 12:10

Master Stroke