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

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

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

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 接收直接链接?我正在尝试获取它,以便我可以从谷歌驱动器流式传输音频文件。

最佳答案

您需要使用song.downloadUrl

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

关于iphone - 谷歌驱动器直接链接到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18174732/

相关文章:

iphone - NSLog - 奇怪的行为

iOS UIPageViewController - 由于未捕获的异常 'Invalid parameter not satisfying: [views count] == 3' 而终止应用程序

ios - 其他框架有类似 NSNotificationCenter 的东西吗?

c# - 如何在 Monotouch 中使用 iOS RespondsToSelector?

security - 为什么我们需要在 oauth 协议(protocol)中从客户端应用程序传递 grant_type ?

java - 无法使用 xoauth 在 javamail 上向 gmail 发送电子邮件

iphone - 核心数据重构

iphone - UIDevice 模型与 localizedModel

powershell - MicrosoftTeams cmdlet 无法使用 AccessToken

iphone - 是否可以将当前的 Modal ViewController 设为 UINavigationController?