0
votes

I know how to download the file from google drive:

GTMOAuth2Authentication *auth =
        [GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:kKeychainItemName
                                                              clientID:kClientID
                                                          clientSecret:kClientSecret];
        [[self driveService] setAuthorizer:auth];

        GTMHTTPFetcher *fetcher =
        [[self driveService].fetcherService fetcherWithURLString:song.filePath];
        [fetcher setReceivedDataBlock:^(NSData *dataReceivedSoFar) {
            [self.mutableData appendData:dataReceivedSoFar];

        }];

        [fetcher beginFetchWithCompletionHandler:^(NSData *data, NSError *error) {
            if (error == nil) {
                // Handle downloaded file
            } else {
                NSLog(@"An error occurred: %@", error);

            }
        }];

But is there a way to obtain direct link to file? Any way to authorize NSUrl to receive a direct link? I am trying to get it so I can stream audio files from google drive.

1
That answer uses GTMHTTPFetcher to download files, however, I am trying to get the direct link so I can stream from it, or download it by using my own methods - vburojevic

1 Answers

2
votes

You need to use song.downloadUrl.

GTMHTTPFetcher *fetcher =
  [service.fetcherService fetcherWithURLString:file.downloadUrl];