上传多部分表单的 AFNetworking 2.0 方法是什么,即使用AFHTTPSessionManager
或AFHTTPRequestOperationManager
下面是一些 AFNetworking < 2.0 代码的示例:
[[ASAPIClient sharedClient] enqueueHTTPRequestOperation:[[ASAPIClient sharedClient] HTTPRequestOperationWithRequest:[[ASAPIClient sharedClient] multipartFormRequestWithMethod:@"POST" path:@"/some/url" parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
if(_selectedPhoto.image)
{
NSData *imageData = UIImageJPEGRepresentation([_selectedPhoto image], 0.5);
[formData appendPartWithFileData:imageData name:@"avatar" fileName:@"avatar.jpg" mimeType:@"image/jpeg"];
}
}] success:^(AFHTTPRequestOperation *operation, id responseObject) {
if([[responseObject objectForKey:@"result"]isKindOfClass:[NSDictionary class]] )
{
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}]];