Created
October 21, 2016 10:52
-
-
Save fel-cesar/c638b5bb47d57f4050c4232feee64d51 to your computer and use it in GitHub Desktop.
Example CloudStorage Swift 3
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 : CloudStorageProtocol = Box.init(clientId: "ClientID", clientSecret: "ClientSecret") | |
//let cloudStorage : CloudStorageProtocol = GoogleDrive.init(clientId: "ClientID", clientSecret: "ClientSecret") | |
//let cloudStorage : CloudStorageProtocol = OneDrive.init(clientId: "ClientID", clientSecret: "ClientSecret") | |
//let cloudStorage : CloudStorageProtocol = Dropbox.init(clientId: "ClientID", clientSecret: "ClientSecret") | |
let cloudStorage : CloudStorageProtocol = Egnyte.init(domain: "DOMAIN", clientId: "[CLIENT]", clientSecret: "[SECRET]", redirectUri: "[REDIRECTURI]", state: "ANY") | |
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)! | |
DispatchQueue.global(qos: .background).async { | |
DispatchQueue.main.async { | |
do{ | |
try cloudStorage.uploadFileToPath(path, stream: stream, size: CLong(fileSize), overwrite: false) | |
} 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