Cloudrail-IOS

이 섹션에서는 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