0

How to solve the crashing in ASIHttpRequest.m file. I'm sending Uiimage to server by bytes format,

NSMutableData *imageData = [UIImageJPEGRepresentation(image, 1.0f) mutableCopy];
    [request setPostBody:imageData];
    [request addRequestHeader:@"fileName" value:[[imageArray objectAtIndex:selectedIndex] filename]];
 [request setDelegate:self];
[request startAsynchronous];

But app crashing fail with error method.

2 Answers 2

0

Why are you setting header of the image type.Just set Post header and responsetype header.And after getting image data just make it encoded.

3
  • But the server side they are getting the header response type.In stream format.
    – Friend
    Aug 13, 2013 at 5:24
  • this is my crashing Line code in ASIHttpRequest.m file,if (theError && [theError code] != ASIAuthenticationErrorType && [theError code] != ASITooMuchRedirectionErrorType)
    – Friend
    Aug 13, 2013 at 5:40
  • Which encoding you are using for image posting.?? They have to use the same encoder and decoder.
    – NHS
    Aug 13, 2013 at 7:38
0

you can try out of two method

[request setFile:@"File Path" withFileName:@"image.png" andContentType:@"image/png" forKey:@"file"];

[request setData:Data withFileName:@"image.png" andContentType:@"image/png" forKey:@"file"];
2
  • Its ok,but I need to post header data for this image.
    – Friend
    Aug 13, 2013 at 5:31
  • this is my crashing Line code in ASIHttpRequest.m file,if (theError && [theError code] != ASIAuthenticationErrorType && [theError code] != ASITooMuchRedirectionErrorType)
    – Friend
    Aug 13, 2013 at 5:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.