📅  最后修改于: 2020-10-30 14:12:12             🧑  作者: Mango
本节介绍如何使用CloudRail的iOS SDK。
最简单的安装方法是通过CocoaPods 。只需将以下内容添加到您的podfile中–
pod "cloudrail-si-ios-sdk"
确保“ use_frameworks!”标志已设置并运行
Pod install
以下示例显示了如何从Objective-C和Swift中的任何云存储提供商下载文件。
objective-c
// self.service = [[CROneDrive alloc] initWithClientId:@"clientIdentifier" clientSecret:@"clientSecret" redirectUri:@"REDIRURL" state:@"CRSTATE"];
// self.service = [[CRGoogleDrive alloc] initWithClientId:@"clientIdentifier" clientSecret:@"clientSecret" redirectUri:@"REDIRURL" state:@"CRSTATE"];
// self.service = [[CRBox alloc] initWithClientId:@"clientIdentifier" clientSecret:@"clientSecret" redirectUri:@"REDIRURL" state:@"CRSTATE"];
[CRCloudRail setAppKey:@"CLOUDRAIL_API_KEY"];
self.service = [[CRDropbox alloc] initWithClientId:@"clientIdentifier"
clientSecret:@"clientSecret" redirectUri:@"REDIRURL" state:@"CRSTATE"];
NSInputStream * object = [self.service downloadFileWithPath:@"/mudkip.jpg"];
//READ FROM STREAM
swift
//let cloudStorage : CloudStorageProtocol = Box.init(clientId: "ClientID", clientSecret: "ClientSecret")
//let cloudStorage : CloudStorageProtocol = GoogleDrive.init(clientId: "ClientID", clientSecret: "ClientSecret")
//let cloudStorage : CloudStorageProtocol = OneDrive.init(clientId: "ClientID", clientSecret: "ClientSecret")
CRCloudRail.setAppKey("CLOUDRAIL_API_KEY")
let cloudStorage : CloudStorageProtocol = Dropbox.init(
clientId: "ClientID", clientSecret: "ClientSecret")
do {
let inputStream = try cloudStorage.downloadFileWithPath("/TestFolder/Data.csv")
} catch let error{
print("An error: \(error)")
}
//READ FROM STREAM