【问题标题】:Image uploading error after update the xcode更新xcode后图片上传错误
【发布时间】:2014-12-04 04:56:24
【问题描述】:

我正在使用 AFNetworking,我正在使用图片上传功能。

它运行良好。现在我将 XCode 更新到最新版本。 XCode 6.0.1。之后,我更新了所有 pods 文件。但现在它不起作用。我没有改变任何东西。

XCode 5.1 和 XCode 6.0.1 两个版本我使用的是 AFNetworking 2.2.4。

我的代码是

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

                NSString *boundary = @"---------------------------14737809831466499882746641449";
                NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
                [request setValue:contentType               forHTTPHeaderField: @"Content-Type"];
                [request setValue:@"Keep-Alive"             forHTTPHeaderField:@"Connection"];
                [request setValue:@"multipart/form-data"    forHTTPHeaderField:@"ENCTYPE"];
                [request setValue:@"test"                   forHTTPHeaderField:@"uploaded_file"];

                NSError *error = nil;
                request = [self.requestSerializer multipartFormRequestWithMethod:@"POST"
                                                                       URLString:APIURL
                                                                      parameters:nil
                                                       constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
                                                           [formData appendPartWithFileData:horse.imageData
                                                                                       name:@"uploaded_file"
                                                                                   fileName:@"myimage.jpg"
                                                                                   mimeType:@"image/jpeg"];
                                                       }
                                                                           error:&error];


                AFHTTPRequestOperation *operation =
                [self HTTPRequestOperationWithRequest:request
                                              success:^(AFHTTPRequestOperation *operation, id responseObject) {



                                              } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                                                  NSLog(@"Failure %@", error.description);
                                              }];

                [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
                    NSLog(@"Wrote %ld/%ld", (long)totalBytesWritten, (long)totalBytesExpectedToWrite);
                }];

                [operation start];

错误信息

** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -streamStatus only defined for abstract class.  Define -[AFMultipartBodyStream streamStatus]!'
*** First throw call stack:
(0x2d656ecb 0x37df1ce7 0x2d656e0d 0x2e033bcb 0x2e03be35 0x23d4f3 0x2d5ab97b 0x2d25a6cb 0x2d2ea0c7 0x2d242e3d 0x2d259d3f 0x2d2592cb 0x2d2590a7 0x2d29f0d7 0x2d242e3d 0x2d258ac5 0x2d2a8cf7 0x2d2580d9 0x2d257f39 0x2d25622d 0x2d255d51 0x2d2ad1cd 0x2d58a159 0x2d25299b 0x2d252859 0x2d2526e9 0x2d621faf 0x2d621477 0x2d61fc67 0x2d58a729 0x2d58a50b 0x2dfcb241 0x2e040a0f 0x3840d959 0x3840d8cb 0x3840bae8)
libc++abi.dylib: terminating with uncaught exception of type NSException

有什么问题并解释我。

【问题讨论】:

  • 更新 AFNetworking 库。我遇到了同样的问题,更新库解决了这个问题。
  • 谢谢....它正在工作

标签: ios xcode5 xcode6 afnetworking-2


【解决方案1】:

这里我使用的是旧的 AFNetwoking。我将 AFNetworking 2.2.4 更改为 2.4.1。然后它正在工作。 无论如何感谢@n00bProgrammer

【讨论】:

    猜你喜欢
    • 2012-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多