谷歌驱动器直接链接到文件

时间:2013-08-11 17:33:44

标签: iphone ios oauth-2.0 google-drive-api

我知道如何从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);

            }
        }];

但有没有办法获得直接链接到文件?有权授权NSUrl接收直接链接吗?我想要它,所以我可以从谷歌驱动器流式传输音频文件。

1 个答案:

答案 0 :(得分:2)

您需要使用song.downloadUrl

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