Skip to content

Instantly share code, notes, and snippets.

@fel-cesar
Created November 9, 2016 16:45
Show Gist options
  • Save fel-cesar/bbae516653f8710d6f712c52f3bce124 to your computer and use it in GitHub Desktop.
Save fel-cesar/bbae516653f8710d6f712c52f3bce124 to your computer and use it in GitHub Desktop.
//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