· 9 years ago · Dec 07, 2016, 02:36 PM
1CRCloudRail.setAppKey("CLOUDRAIL_API_KEY")
2
3//let cloudStorage : BusinessCloudStorageProtocol = Backblaze.init(accountID: "[account_id]", appKey: "[app_key]")
4//let cloudStorage : BusinessCloudStorageProtocol = Rackspace.init(username: "[username]", apiKey: "[api_key]", region: "[region]")
5//let cloudStorage : BusinessCloudStorageProtocol = MicrosoftAzure.init(accountName: "[account_name]", accessKey: "access_key")
6let cloudStorage : BusinessCloudStorageProtocol = AmazonS3.init(accessKeyId: "[access_key]", secretAccessKey: "[secret_key]", region: "[region]")
7
8let bucket : CRBucket = CRBucket.init()
9bucket.name = "[bucketName]";
10bucket.identifier = "[identifier]"
11
12let path = Bundle.main.path(forResource: "UserData", ofType: "csv")!
13let fileAttributes = try! FileManager.default.attributesOfItem(atPath: path)
14let fileSize: UInt64 = fileAttributes[FileAttributeKey.size] as! UInt64
15let stream = InputStream.init(fileAtPath: path)!
16
17do{
18 try cloudStorage.uploadFileToBucket(bucket, name: "[fileName]", stream: stream, size:fileSize)
19} catch let error{
20 print("An error: \(error)")
21}