【发布时间】:2016-02-18 06:08:28
【问题描述】:
我正在使用 REST 服务的 restkit 库。我不知道如何发送多个图像,我可以发送单个图像,我不知道。
[LoadingView showInView:[[UIApplication sharedApplication].delegate window]];
NSString *url=@"/upload";
NSDictionary *dic=@{@"userId":[self.appUtil getDataForKey:@"USERID"]};
NSMutableURLRequest *request = [[RKObjectManager sharedManager] multipartFormRequestWithObject:nil method:RKRequestMethodPOST path:url parameters:dic constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:UIImagePNGRepresentation(imgProfile.image)
name:@"file"
fileName:@"photo.png"
mimeType:@"image/png"];
}];
RKObjectRequestOperation *operation = [[RKObjectManager sharedManager] objectRequestOperationWithRequest:request success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult){
NSString* userString=operation.HTTPRequestOperation.responseString;
NSLog(@"%@",userString);
NSError* error = nil;
[LoadingView removeFromView:[[UIApplication sharedApplication].delegate window]];
StatusInnner *state=[[StatusInnner alloc]initWithString:userString error:&error];
if (state!=nil) {
if ([state.status.status isEqualToString:@"200"]) {
[self.appUtil createSimpleAlertView:self title:string_title_success
message:state.status.msg];
}else{
[self.appUtil createSimpleAlertView:self title:string_title_success
message:state.status.msg];
}
}
【问题讨论】:
-
检查我的答案,如果您需要任何帮助,请告诉我