您的位置:首页 > Web前端 > JavaScript

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";

代码如下

<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格式问题,也有可能是其他问题;让后台重新部署生产环境后一切正常;

评论是一种美德,是对作者的一种鼓励,欢迎斧正,谢谢!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐