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
Post a Comment