Created
November 9, 2016 16:45
-
-
Save fel-cesar/bbae516653f8710d6f712c52f3bce124 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//let cloudStorage : BusinessCloudStorageProtocol = Backblaze.init(accountID: "[account_id]", appKey: "[app_key]") | |
//let cloudStorage : BusinessCloudStorageProtocol = Rackspace.init(username: "[username]", apiKey: "[api_key]", region: "[region]") | |
//let cloudStorage : BusinessCloudStorageProtocol = MicrosoftAzure.init(accountName: "[account_name]", accessKey: "access_key") | |
let cloudStorage : BusinessCloudStorageProtocol = AmazonS3.init(accessKeyId: "[access_key]", secretAccessKey: "[secret_key]", region: "[region]") | |
let bucket : CRBucket = CRBucket.init() | |
bucket.name = "[bucketName]"; | |
bucket.identifier = "[identifier]" | |
let path = Bundle.main.path(forResource: "UserData", ofType: "csv")! | |
let fileAttributes = try! FileManager.default.attributesOfItem(atPath: path) | |
let fileSize: UInt64 = fileAttributes[FileAttributeKey.size] as! UInt64 | |
let stream = InputStream.init(fileAtPath: path)! | |
do{ | |
try cloudStorage.uploadFileToBucket(bucket, name: "[fileName]", stream: stream, size:fileSize) | |
} catch let error{ | |
print("An error: \(error)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment