AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager.requestSerializer setValue:uin forHTTPHeaderField:@"uin"];
[manager.requestSerializer setValue:ticket forHTTPHeaderField:@"ticket"];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"];
[manager POST:kUploadFileUrl
parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
if (isImage) {
[formData appendPartWithFileData:fileData name:@"file" fileName:@"file.jpg" mimeType:@"image/jpg"];
} else {
[formData appendPartWithFileData:fileData name:@"file" fileName:@"file.mov" mimeType:@"video/quicktime"];
}
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"%@",responseObject);
complete(responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@",error);
}];
如果报1066,1011的错误都是请求格式和返回格式的问题
解决方法就是添加
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];