recherche

Maison  >  Questions et réponses  >  le corps du texte

ios - 上传图片时出现无法解析响应,是什么情况,code= -1017

PHP中文网PHP中文网2772 Il y a quelques jours1313

répondre à tous(2)je répondrai

  • 大家讲道理

    大家讲道理2017-04-17 17:53:02

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    manager.responseSerializer.acceptableContentTypes=[NSSet setWithObject:@"application/json"];
    [manager POST:stringUrl parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
        [formData appendPartWithFileData:imageData name:@"imageFile"fileName:@"avatar.jpg"mimeType:@"image/jpg/file/png"];
    } success:^(AFHTTPRequestOperation *operation, NSData * responseObject) {
        [MBProgressHUD stopMBProgressHUD:self.view];
        NSData *doubi = responseObject;
        NSDictionary * dataDic = [NSJSONSerialization JSONObjectWithData:doubi options:NSJSONReadingAllowFragments error:nil];
        
        // 成功 返回一个图片Url地址
       
            
       
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];

    répondre
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 17:53:02

    NSURLErrorCannotParseResponse =             -1017,
    

    可能是返回数据的类型有问题。

    répondre
    0
  • Annulerrépondre