0

我知道如何从谷歌驱动器下载文件:

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);

            }
        }];

但是有没有办法获得文件的直接链接?有什么方法可以授权 NSUrl 接收直接链接?我正在尝试获取它,以便可以从谷歌驱动器流式传输音频文件。

4

1 回答 1

2

你需要使用song.downloadUrl.

GTMHTTPFetcher *fetcher =
  [service.fetcherService fetcherWithURLString:file.downloadUrl];
于 2013-08-12T12:19:06.157 回答