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