'Invalid parameter not satisfying: body'
afnetwork图片上传的时候出错,出现错误
2015-11-09 15:47:59.086 videoPro[3207:132795] *** Assertion failure in -[AFStreamingMultipartFormData appendPartWithHeaders:body:], /Users/zhanglingxiang/Documents/videoPro/AFNetworking/AFURLRequestSerialization.m:793
2015-11-09 15:48:01.655 videoPro[3207:132795] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: body'
代码:
NSData *imageData = UIImageJPEGRepresentation(image,0.1f);
//转码成UTF-8 否则可能会出现错误
NSString *URLTmp = [NSString stringWithFormat:@"%@/photoUpload",SERVER];
NSString *URLTmps = [URLTmp stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
URLTmp = URLTmps;
NSDictionary* dic = [NSDictionary dictionaryWithObject:self.userName forKey:@"user"];
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:URLTmp parameters:dic constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:imageData name:@"headerImg" fileName:@"123.png" mimeType:@"image/png"];
} error:nil];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
NSProgress *progress = nil;
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
NSLog(@"%@",responseObject);
NSDictionary* dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
NSString* strHead = [NSString stringWithFormat:@"%@/%@",IMGSERVER,dic[@"url"]];
// [[NSUserDefaults standardUserDefaults] setObject: forKey:@"userHead"];
[imageView sd_setImageWithURL:[NSURL URLWithString:strHead]];
//头像上传成功
MBProgressHUD* hud = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:hud];
hud.mode = MBProgressHUDModeCustomView;
hud.labelText = @"头像上传成功";
[hud showAnimated:YES whileExecutingBlock:^{
sleep(2);
} completionBlock:^{
[hud removeFromSuperview];
return;
}];
}
}];
[uploadTask resume];
改了几种方法,都不行,最后发现是image没有值,也是醉了。。
'Invalid parameter not satisfying: body'的更多相关文章
- IOS 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: URLString'
转载自:http://i.cnblogs.com/EditPosts.aspx?postid=4012011 今天想写一个请求的天气,好的,废话不多说,先贴代码: 使用AFNetWorking 发送g ...
- iOS 9 地图定位崩溃 n: 'Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient)'
报错详情: *** Assertion failure in -[CLLocationManager setAllowsBackgroundLocationUpdates:], /BuildRoot/ ...
- iOS文件上传文件URL错误Invalid parameter not satisfying: fileURL'
一:iOS文件上传提示URL错误 Invalid parameter not satisfying: fileURL' 二:解决方法: NSString *imagePath = [[NSBundle ...
- 安装yii2时出错 Invalid Parameter – yii\base\InvalidParamException
最近composer安装yii2的时候页面报了这个错,应该是bower的前端资源位置改变的缘故! Invalid Parameter – yii\base\InvalidParamException ...
- Oracle 记录插入时“Invalid parameter binding ”错误
出现这种错误的原因可能有一下几种: 由于OracleParameter[] parameters:中parameters的个数和对应的插入SQL语句中的冒号个数不等: 参数个数和冒号个数相等,但是如下 ...
- 关于ImageMagick出现无效参数(invalid parameter)的解决方法
Windows 命令行 运行"convert logo.jpg f:\parseWord\tmp\logo.png" 时显示 “无效参数(Invalid Parameter)” ...
- java.sql.SQLException: Invalid parameter object type. Expected 'java.util.Map' but found 'java.lang.String 转载
java.sql.SQLException: Invalid parameter object type. Expected 'java.util.Map' but found 'java.lang. ...
- Failed to set MokListRT: Invalid Parameter Something as gone seriously wrong: import_mok_state() failed: Invalid Parameter
今天yum update升级centos7,重启后发现开不了机,报错如下: Failed to set MokListRT: Invalid ParameterSomething as gone se ...
- 源码剖析Yii错误 Invalid parameter number: no parameters were bound
ActiveRecord使用的一个陷阱导致 Invalid parameter number: no parameters were bound 请看下面的例子 $criteria = new CDb ...
随机推荐
- Swift语言—有趣的字符串连接、数组、字典
字符串链接:Swift语言中的字符串连接方式本人觉得非常的有趣,变量连接需要用右斜杠,并且变量名要括起来 “\(变量名)”,后面的字符串连接分别用逗号 ‘ , ’ 隔开 数组: Var arr = [ ...
- 关于javascript中的===和==
=是赋值符号,==是等于,===是严格等于. 对于等号两边的数值,如果类型不相同会先转换类型再比较,===则不会转换类型. 例如3和“3”在==比较下true,在===下是false, null和un ...
- 判断CAD版本
使用命令: ACADVER ACADVER = "17.2s (LMS Tech)" (只读) CAD2016 ACADVER = "20.1s (LMS Tech)&q ...
- Ubuntu软件中心打不开,Encountered a section with no Package: header错误之解决
sudo rm /var/lib/apt/lists/* -vf sudo apt-get update
- 传智播客JavaWeb day07、day08-自定义标签(传统标签和简单标签)、mvc设计模式、用户注册登录注销
第七天的课程主要是讲了自定义标签.简单介绍了mvc设计模式.然后做了案例 1. 自定义标签 1.1 为什么要有自定义标签 前面所说的EL.JSTL等技术都是为了提高jsp的可读性.可维护性.方便性而取 ...
- 第三个Sprint冲刺第二天
讨论地点:宿舍 讨论成员:邵家文.李新.朱浩龙.陈俊金 讨论问题:强化答案讲解功能
- 【转载】分享一些Qt学习资源,欢迎下载
资源来源:http://bbs.csdn.net/topics/390358737 经过我一翻整理,把一些我收集到的Qt学习资源分享给大家,主要适合新手,老鸟可以直接忽略我.要说明一下,很多资源都是在 ...
- maven 基本常识以及命令
Maven库: http://repo2.maven.org/maven2/ Maven依赖查询: http://mvnrepository.com/ Maven常用命令: 1. 创建Maven的普通 ...
- remove adapter
Although adapter and other technical sequences can potentially occur in any location within reads, b ...
- LintCode Maximum Depth of Binary Tree
1 /** * Definition of TreeNode: * public class TreeNode { * public int val; * public TreeNode left, ...