ios - RestKit upload image parameters -


i have configure server side uploading image restkit 0.2 using spring.

i use following code uploading:

nsmutableurlrequest *request = [[rkobjectmanager sharedmanager] multipartformrequestwithobject:obj                                                                                         method:rkrequestmethodpost                                                                                           path:nil                                                                                     parameters:nil                                                                      constructingbodywithblock:^(id<afmultipartformdata> formdata) {       [formdata appendpartwithfiledata:uiimagejpegrepresentation(obj.image, 1.0)                                 name:@"image"                             filename:@"image.jpg"                             mimetype:@"image/jpeg"];  }];    rkobjectrequestoperation *operation = [[rkobjectmanager sharedmanager] objectrequestoperationwithrequest:request                                                                                                  success:^(rkobjectrequestoperation *operation, rkmappingresult *mappingresult) {                                                                                                       nslog(@"%@", [mappingresult firstobject]);                                                                                                   } failure:^(rkobjectrequestoperation *operation, nserror *error) {                                                                                                   }];  [[rkobjectmanager sharedmanager] enqueueobjectrequestoperation:operation]; 

my ws side:

@requestmapping(value = "findmatch", method = requestmethod.post) public void findmatch(@requestparam(value = "image") part image){      // ... } 

when try upload image error: the request sent client syntactically incorrect.

my question is, name of image parameter?

thanks.

solved!

@requestmapping(value = "findmatch", method = requestmethod.post) public void findmatch(httpservletrequest request){       multiparthttpservletrequest multipartrequest = (multiparthttpservletrequest) request;      multipartfile multipartfile = multipartrequest.getfile("image");       // handle file... } 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -