oauth-2.0 Google驱动器直接链接到文件

taor4pac  于 2022-10-31  发布在  Go
关注(0)|答案(1)|浏览(236)

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

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接收直接链接?我正试图获得它,这样我就可以从谷歌驱动器流音频文件。

jyztefdp

jyztefdp1#

您需要使用song.downloadUrl

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

相关问题