我正在开发一个需要在服务器上传图像的应用程序。对于上传图像,我使用以下代码。
AFHTTPRequestOperationManager *manager1 = [AFHTTPRequestOperationManager manager];
manager1.requestSerializer = [AFHTTPRequestSerializer serializer];
[manager1.requestSerializer setValue:@"Content-Type" forHTTPHeaderField:@"text/html"];
manager1.responseSerializer = [AFJSONResponseSerializer serializer];
manager1.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
AFHTTPRequestOperation *op= [manager1 POST:urlString parameters:Nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:imageData name:@"photo" fileName:[NSString stringWithFormat:@"%@.jpeg",timeStamp] mimeType:@"image/jpeg"];
}success:^(AFHTTPRequestOperation *operation, id responseObject) { }failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[self dismissLoading];}];[op start];
我的问题是,当我从Xcode 5运行相同的代码到iPad 2 iOS 8.1时,它会正常工作。但是,当我将相同的代码从Xcode 6.1运行到相同的iPad 2 iOS 8.1时,它会让请求超时。
请帮忙..!
答案 0 :(得分:0)
几天前我也遇到了与AFHTTPRequestOperationManager相同的问题。我无法使用xcode 6在服务器上上传图像。但是当我解决警告(https://github.com/AFNetworking/AFNetworking/commit/0ae246896e2327a31d26dcb998375af8fe9209a2)时,它的工作正常。希望这能帮助你和其他人:)