AFNetWorking上传图片失败(返回JSON格式不对)
2015-02-03 16:43
357 查看
上传一张图片到服务器,测试环境一切正常,生产环境提示上传失败,但服务器已经有此图片,而且返回状态是成功,打印错误日志如下:
Printing description of error:
Error Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 404" UserInfo=0x19069080 {NSLocalizedRecoverySuggestion=
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
错误信息!
<a href=/CubeCoreConsole>返回主页</a>
<a href="javascript:history.go(-1);">返回上一页</a>
<br>
<div style="color: #F00;">
</div>
</body>
</html>, AFNetworkingOperationFailingURLRequestErrorKey=<NSMutableURLRequest: 0x17e20f50> { URL: http://www.hybchina.com.cn/CubeCoreConsole/mpos/syncMpos.do }, NSErrorFailingURLKey=http://www.hybchina.com.cn/CubeCoreConsole/mpos/syncMpos.do, NSLocalizedDescription=Expected
status code in (200-299), got 404, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x17e27e60> { URL: http://www.hybchina.com.cn/CubeCoreConsole/mpos/syncMpos.do } { status code: 404, headers {
Connection = "keep-alive";
"Content-Length" = 438;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Tue, 03 Feb 2015 05:01:18 GMT";
Server = "nginx/1.6.2";
代码如下:
怀疑返回数据有问题,解析不出来,有可能是JSON格式问题,也有可能是其他问题;让后台重新部署生产环境后一切正常;
评论是一种美德,是对作者的一种鼓励,欢迎斧正,谢谢!
Printing description of error:
Error Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 404" UserInfo=0x19069080 {NSLocalizedRecoverySuggestion=
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
错误信息!
<a href=/CubeCoreConsole>返回主页</a>
<a href="javascript:history.go(-1);">返回上一页</a>
<br>
<div style="color: #F00;">
</div>
</body>
</html>, AFNetworkingOperationFailingURLRequestErrorKey=<NSMutableURLRequest: 0x17e20f50> { URL: http://www.hybchina.com.cn/CubeCoreConsole/mpos/syncMpos.do }, NSErrorFailingURLKey=http://www.hybchina.com.cn/CubeCoreConsole/mpos/syncMpos.do, NSLocalizedDescription=Expected
status code in (200-299), got 404, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x17e27e60> { URL: http://www.hybchina.com.cn/CubeCoreConsole/mpos/syncMpos.do } { status code: 404, headers {
Connection = "keep-alive";
"Content-Length" = 438;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Tue, 03 Feb 2015 05:01:18 GMT";
Server = "nginx/1.6.2";
代码如下:
<span style="color:#3333ff;">NSMutableURLRequest *request = [[AFAppDotNetAPIClient sharedClient] multipartFormRequestWithMethod:@"POST" path:@"mpos/syncMpos.do" parameters:self.myDic constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) { [formData appendPartWithFileData:imageData name:@"aphoto" fileName:@"aphoto.png" mimeType:@"image/png"]; }]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { if ([JSON[@"status"] isEqualToString:@"1"]) { [self showMessage:@"签名上传成功"];} }failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) { [MBProgressHUD hideAllHUDsForView:self.view animated:YES]; [self showAlter]; }]; [operation start];</span>
怀疑返回数据有问题,解析不出来,有可能是JSON格式问题,也有可能是其他问题;让后台重新部署生产环境后一切正常;
评论是一种美德,是对作者的一种鼓励,欢迎斧正,谢谢!
相关文章推荐
- Ueditor图片上传成功后,返回json数据格式
- ie下面用iframe实现图片上传,返回json格式时提示打开或保存。
- [图片处理]PHP对非标准格式的图片pjpeg上传失败的解决办法
- 中国天气网接口返回json格式分析及接口(XML、图片接口)说明!
- 全局异常处理器&上传图片&json格式& restfull&拦截器
- 中国天气网接口返回json格式分析及接口(XML、图片接口)说明!
- 关于ext与springMVC中上传文件并以JSON格式返回入STORE的问题
- ASP.NET MVC上传文件成功返回Json格式数据弹出下载框解决方案
- AFNetworking 批量上传统一返回图片的3种方法
- extjs 上传文件或是图片后返回json解析错误
- ajaxFileupload.js修复上传无法携带参数,返回json格式不准确问题
- struts2 + ajax(由前台的form提交数据到后台,再根据form所调用返回获取的后台json格式的数据返回到前端,然后前端用jquery对json数据进行解析)==》》涉及非文件上传的部分
- 中国天气网接口返回json格式分析及接口(XML、图片接口)说明
- 如何解决jersey框架中以json格式返回数组,当数组中元素一个时json格式不对
- android使用json数据格式同时上传图片和文本
- EXTJS FROM表单返回值JSON数据格式,当上传图片的时候特别注意
- 中国天气网接口返回json格式分析及接口(XML、图片接口)说明!
- SpringMVC+EXTJS4.1上传文件,并通过JSON格式返回异常信息
- AFNetworking实现POST上传文件——图片、.json、MP4,,,,,等各种类型。
- 使用json方式上传图片时,发现上传成功后,变成下载了json... 或者无法解析到返回的结果集!!!