All, I am using RestKit for iOS to upload a JPEG file to my Java web service. I referred to this
tutorial for developing file upload web service and it works perfectly fine when i use it through my web browser.
However, when i try to upload a file using RESTKit then in TOMCAT logs i get HTTP/1.1 200 213 status code and my file is not uploaded.
Here is my RESTKit code:
RKObjectManager* manager = [RKObjectManager sharedManager];
RKObjectLoader* objectLoader = [manager objectLoaderWithResourcePath:@"/fileuploaded" delegate:self];
objectLoader.method = RKRequestMethodPOST;
UIImage *image = [UIImage imageNamed:@"rental_car_bill.jpeg"];
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
// attach image
RKParams *params = [RKParams paramsWithDictionary:(NSDictionary*)objectLoader.params];
RKParamsAttachment *attachment = [params setData:imageData
MIMEType:@"image/jpeg" forParam:@"photo"];
attachment.fileName = @"samplejpeg";
objectLoader.params = params;
objectLoader.targetObject = self;
[objectLoader send];
EDIT: Above implementation does work and the file does get uploaded. However, in the delegate method: - (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects
After it gets out of the scope of this, then my application crashes at [RKObjectLoader dealloc];