Permalink
Browse files

Made image size smaller, replaced digest auth end url

  • Loading branch information...
MugunthKumar committed Mar 7, 2012
1 parent f9984d4 commit c085c130b3d0235ff5c0ed2538bdf3e1abd2e7ff
@@ -203,7 +203,7 @@
ABB5C253148B3AE00056D3E9 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0420;
+ LastUpgradeCheck = 0430;
ORGANIZATIONNAME = Steinlogic;
};
buildConfigurationList = ABB5C256148B3AE00056D3E9 /* Build configuration list for PBXProject "MKNetworkKit-iOS" */;
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -180,7 +180,7 @@
AB74B0B41467CC120088BF09 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0420;
+ LastUpgradeCheck = 0430;
ORGANIZATIONNAME = Steinlogic;
};
buildConfigurationList = AB74B0B71467CC120088BF09 /* Build configuration list for PBXProject "MKNetworkKit-iOS-Demo" */;
@@ -46,5 +46,5 @@
@end
-#define kTwitterUserName @""
-#define kTwitterPassword @""
+#define kTwitterUserName @"icashsg"
+#define kTwitterPassword @"51+z`huMhH5i(V5o"
@@ -13,4 +13,8 @@
-(void)digestAuthTestWithUser:(NSString*)username password:(NSString*)password;
-(void) clientCertTest;
-(int) cacheMemoryCost;
+
+-(MKNetworkOperation*) uploadImageFromFile:(NSString*) file
+ onCompletion:(TwitPicBlock) completionBlock
+ onError:(MKNKErrorBlock) errorBlock;
@end
@@ -11,83 +11,116 @@
@implementation AuthTestEngine
-(void) basicAuthTest {
+
+ MKNetworkOperation *op = [self operationWithPath:@"mknetworkkit/basic_auth.php"
+ params:nil
+ httpMethod:@"GET"];
+
+ [op setUsername:@"admin" password:@"password" basicAuth:YES];
+
+ [op onCompletion:^(MKNetworkOperation *operation) {
- MKNetworkOperation *op = [self operationWithPath:@"mknetworkkit/basic_auth.php"
- params:nil
- httpMethod:@"GET"];
+ DLog(@"%@", [operation responseString]);
+ } onError:^(NSError *error) {
- [op setUsername:@"admin" password:@"password" basicAuth:YES];
-
- [op onCompletion:^(MKNetworkOperation *operation) {
-
- DLog(@"%@", [operation responseString]);
- } onError:^(NSError *error) {
-
- DLog(@"%@", [error localizedDescription]);
- }];
- [self enqueueOperation:op];
+ DLog(@"%@", [error localizedDescription]);
+ }];
+ [self enqueueOperation:op];
}
-(void) digestAuthTest {
+
+ MKNetworkOperation *op = [self operationWithPath:@"mknetworkkit/digest_auth.php"
+ params:nil
+ httpMethod:@"GET"];
+
+ [op setUsername:@"admin" password:@"password"];
+
+ [op onCompletion:^(MKNetworkOperation *operation) {
- MKNetworkOperation *op = [self operationWithPath:@"mknetworkkit/digest_auth.php"
- params:nil
- httpMethod:@"GET"];
-
- [op setUsername:@"admin" password:@"password"];
+ DLog(@"%@", [operation responseString]);
+ } onError:^(NSError *error) {
- [op onCompletion:^(MKNetworkOperation *operation) {
-
- DLog(@"%@", [operation responseString]);
- } onError:^(NSError *error) {
-
- DLog(@"%@", [error localizedDescription]);
- }];
- [self enqueueOperation:op];
+ DLog(@"%@", [error localizedDescription]);
+ }];
+ [self enqueueOperation:op];
}
-(void)digestAuthTestWithUser:(NSString*)username password:(NSString*)password {
- MKNetworkOperation *op = [self operationWithURLString:@"http://teeqemm.dnsalias.org:82/Users/11220/Catalogs/"
- params:nil
- httpMethod:@"GET"];
+ MKNetworkOperation *op = [self operationWithPath:@"mknetworkkit/digest_auth.php"
+ params:nil
+ httpMethod:@"GET"];
+
+ [op setUsername:username password:password];
+ [op setCredentialPersistence:NSURLCredentialPersistenceNone];
+
+ [op onCompletion:^(MKNetworkOperation *operation) {
- [op setUsername:username password:password];
- [op setCredentialPersistence:NSURLCredentialPersistenceNone];
+ DLog(@"%@", [operation responseString]);
+ } onError:^(NSError *error) {
- [op onCompletion:^(MKNetworkOperation *operation) {
-
- DLog(@"%@", [operation responseString]);
- } onError:^(NSError *error) {
-
- DLog(@"%@", [error localizedDescription]);
- }];
- [self enqueueOperation:op];
+ DLog(@"%@", [error localizedDescription]);
+ }];
+ [self enqueueOperation:op];
}
-(void) clientCertTest {
+
+ MKNetworkOperation *op = [self operationWithPath:@"mknetworkkit/client_auth.php"
+ params:nil
+ httpMethod:@"GET"
+ ssl:YES];
+
+ NSString *certPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"client.p12"];
+ [op setClientCertificate:certPath];
+
+ [op onCompletion:^(MKNetworkOperation *operation) {
+
+ DLog(@"%@", [operation responseString]);
+ } onError:^(NSError *error) {
- MKNetworkOperation *op = [self operationWithPath:@"mknetworkkit/client_auth.php"
- params:nil
- httpMethod:@"GET"
- ssl:YES];
+ DLog(@"%@", [error localizedDescription]);
+ }];
+ [self enqueueOperation:op];
+}
+
+-(MKNetworkOperation*) uploadImageFromFile:(NSString*) file
+ onCompletion:(TwitPicBlock) completionBlock
+ onError:(MKNKErrorBlock) errorBlock {
+
+ MKNetworkOperation *op = [self operationWithPath:@"mknetworkkit/upload.php"
+ params:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"YES", @"Submit",
+ nil]
+ httpMethod:@"POST"];
+
+ [op addFile:file forKey:@"image"];
+
+ // setFreezable uploads your images after connection is restored!
+ [op setFreezable:YES];
+
+ [op onCompletion:^(MKNetworkOperation* completedOperation) {
- NSString *certPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"client.p12"];
- [op setClientCertificate:certPath];
+ NSString *xmlString = [completedOperation responseString];
- [op onCompletion:^(MKNetworkOperation *operation) {
-
- DLog(@"%@", [operation responseString]);
- } onError:^(NSError *error) {
-
- DLog(@"%@", [error localizedDescription]);
- }];
- [self enqueueOperation:op];
+ DLog(@"%@", xmlString);
+ completionBlock(xmlString);
+ }
+ onError:^(NSError* error) {
+
+ errorBlock(error);
+ }];
+
+ [self enqueueOperation:op];
+
+
+ return op;
}
-(int) cacheMemoryCost {
- return 0;
+ return 0;
}
@end
@@ -105,7 +105,7 @@ -(IBAction)uploadImageTapped:(id)sender {
return;
}
NSString *uploadPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingFormat:@"/SampleImage.jpg"];
- self.uploadOperation = [ApplicationDelegate.twitPicUploader uploadImageFromFile:uploadPath
+ self.uploadOperation = [ApplicationDelegate.sampleAuth uploadImageFromFile:uploadPath
onCompletion:^(NSString *twitPicURL) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Uploaded to"

0 comments on commit c085c13

Please sign in to comment.