8

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.

Master Stroke
  • 5,108
  • 2
  • 26
  • 57
NextStep
  • 429
  • 5
  • 20

2 Answers2

5

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.

Master Stroke
  • 5,108
  • 2
  • 26
  • 57
  • i m using "audio/mpeg" for audio files dude than also it getting null value – NextStep Sep 12 '13 at 11:56
  • sorry i dont have hand on experience with audio/video type streaming directly from gdrive...i think it needs authentication phase...search for the file types supported for this... – Master Stroke Sep 12 '13 at 12:01
  • it is possible to get exportslinks. if u explain how it would help me alot – NextStep Sep 20 '13 at 09:12
  • bro...really it is possible to get public url.. i tried lot but still no..plz reply – NextStep Sep 23 '13 at 09:29
  • @James...show me what you tried?..you just can't downvote any answer if you don't know how to implement it... – Master Stroke Sep 26 '13 at 05:16
  • i dont have that much repu.. to down vote ur answer.. buy i m shocked to see upvote for ur answer...which is not all all relating my prob – NextStep Sep 26 '13 at 05:19
  • @James...have gone though the google api?...i mean the how they implemented the class called DriveSampleWindowController...if not then click here...http://pastebin.com/ZR6RLjtt – Master Stroke Sep 26 '13 at 05:22
  • i have tried http://stackoverflow.com/q/18443564/2632749 to get file.downloadUrl..when ever i pass that url to the browser it asks to authenticate. I have checked in file,JsonString...there token expires immediately.. If u could get my prob plz reply – NextStep Sep 26 '13 at 05:23
  • @James...i too cant really take the responsible for who upvotes/downvotes my answers/question...u said its not related to your problem?...my question is GTLDriveFile *file = [driveFiles objectAtIndex:indexPath.row]; exportURLStr = [NSString stringWithFormat:@"%@",file.exportLinks]; ==>is this the correct way?..ultimately NO... – Master Stroke Sep 26 '13 at 05:24
  • @James..sorry for that..i dont have google api with me...or else i would have tried for you.... – Master Stroke Sep 26 '13 at 05:25
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/38068/discussion-between-james-and-puneeth-kamath) – NextStep Sep 26 '13 at 05:28
0

A file will either have a downloadUrl or a set of exportLinks. Not both. exportLinks is for converting native Google docs into a PC format (eg Google spreadsheet to .xls).

I think webContentLink may be the property you need to use.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
  • what kind of file is it? It might be helpful to past the complete files resource into your question – pinoyyid Sep 12 '13 at 14:01
  • https://docs.google.com/uc?id=0Bwq4tOH28NcUQ3Mxd2lmQVJFOUEexport=download i m getting this link but it is not opening in browser.. – NextStep Sep 12 '13 at 14:02
  • i tried alot to find prob but not able to get solution. I am able to download and play.. But i want to stream – NextStep Sep 12 '13 at 14:04
  • Check the headers in the response using Chrome Devtools. I suspect you'll see "content-disposition:attachment;" which instructs the browser to download rather than render the content. afaik there is no way to ask Google to change this header so you might need to proxy the request. – pinoyyid Sep 12 '13 at 16:00
  • I think there r player in app store and they are streaming from google drive directly... – NextStep Sep 12 '13 at 16:55
  • @pinoyyid... hi r u there – NextStep Sep 23 '13 at 06:02