vendredi 6 mars 2015

Base54 Encoded string failed in ASIHttpFormDataRequest

Please check my code:



NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://ift.tt/1NoPf2R",baseUrl]];

//////NSLog(@"URL:%@",url);

__block ASIFormDataRequest *requestmethod = [ASIFormDataRequest requestWithURL:url];


NSUserDefaults *loginCheck=[NSUserDefaults standardUserDefaults];



NSString *loginValidation=[loginCheck valueForKey:@"USER_ID"];

UIImage *img = [UIImage imageNamed:@"overlaygraphic.png"];


NSData *imageData = UIImageJPEGRepresentation(img, 1.0);

NSString *encodedString = [imageData base64Encoding];




[requestmethod setValidatesSecureCertificate:NO];
[requestmethod setPostValue:@"196" forKey:@"checkindetlid"];

[requestmethod setPostValue:[NSString stringWithFormat:@"%@",encodedString] forKey:@"imgpath"];


[requestmethod setPostValue:@"" forKey:@"description"];
[requestmethod setPostValue:@"0" forKey:@"id"];

[requestmethod setPostValue:@"" forKey:@"content"];
[requestmethod setPostValue:@"0" forKey:@"offset"];

[requestmethod setPostValue:@"mRHcXXatqUayMNyP8nlEmA==" forKey:@"usrToken"];
[requestmethod setPostValue:@"KLB050572RC" forKey:@"equipmentid"];


//[requestmethod setPostFormat:ASIMultipartFormDataPostFormat];

[requestmethod setTimeOutSeconds:500];




[requestmethod setCompletionBlock:^{
NSString *responseString23 = [requestmethod responseString];


NSLog(@"Image Response:%@",responseString23);




}];
[requestmethod setFailedBlock:^{




NSError *error = [requestmethod error];

NSLog(@"%@",error.localizedDescription);






}];

[requestmethod startAsynchronous];


My need is :




  1. Convert UIImage to Base64 String - Its completed




  2. Post this values to server. But server always displays null value. Instead of post base64 string to any other string Its worked correctly.



    [requestmethod setPostValue:[NSString stringWithFormat:@"%@",encodedString] forKey:@"imgpath"];





Aucun commentaire:

Enregistrer un commentaire