Last active
October 21, 2016 10:10
-
-
Save fel-cesar/f7a038b7a6ee88e403bdc47dd7afcaf3 to your computer and use it in GitHub Desktop.
Example CloudStorage Objective-C
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
// id<CRCloudStorageProtocol> cs = [[CROneDrive alloc] initWithClientId:@"[CLIENT]" clientSecret:@"[SECRET]"]; | |
// id<CRCloudStorageProtocol> cs= [[CRGoogleDrive alloc] initWithClientId:@"[CLIENT]" clientSecret:@"[SECRET]"]; | |
// id<CRCloudStorageProtocol> cs = [[CRBox alloc] initWithClientId:@"[CLIENT]" clientSecret:@"[SECRET]" ]; | |
// id<CRCloudStorageProtocol> cs = [[CRDropbox alloc] initWithClientId:@"[CLIENT]" clientSecret:@"[SECRET]"]; | |
id<CRCloudStorageProtocol> cs = [[CREgnyte alloc] initWithDomain:@"[DOMAIN]" clientId:@"[CLIENT]" clientSecret:@"" redirectUri:@"[SECRET]" state:@"ANY"]; | |
NSString * path = [[NSBundle mainBundle] pathForResource:@"UserData" ofType:@"csv"]; | |
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil]; | |
long fileSize = [fileAttributes fileSize]; | |
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ | |
//Background Thread | |
NSInputStream * stream = [NSInputStream inputStreamWithFileAtPath:path]; | |
dispatch_async(dispatch_get_main_queue(), ^(void){ | |
//Run UI Updates | |
@try { | |
[cs uploadFileToPath:@"/Shared/Documents/TestFolder/Data.csv" withStream:stream size:fileSize overwrite:NO]; | |
} @catch (NSException *exception) { | |
//TODO: Exception handling | |
} @finally { | |
//TODO: close the stream | |
} | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment