Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. CRCloudRail.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")
  6. let cloudStorage : BusinessCloudStorageProtocol = AmazonS3.init(accessKeyId: "[access_key]", secretAccessKey: "[secret_key]", region: "[region]")
  7.  
  8. let bucket : CRBucket = CRBucket.init()
  9. bucket.name = "[bucketName]";
  10. bucket.identifier = "[identifier]"
  11.  
  12. let path = Bundle.main.path(forResource: "UserData", ofType: "csv")!
  13. let fileAttributes = try! FileManager.default.attributesOfItem(atPath: path)
  14. let fileSize: UInt64 = fileAttributes[FileAttributeKey.size] as! UInt64
  15. let stream = InputStream.init(fileAtPath: path)!
  16.  
  17. do{
  18. try cloudStorage.uploadFileToBucket(bucket, name: "[fileName]", stream: stream, size:fileSize)
  19. } catch let error{
  20. print("An error: \(error)")
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement