AFNetworking을 사용하여 웹 서버에 다중 파트 양식을 보내고 있습니다. 내 AFHTTPRequestOperation
에 문제가 있습니다. 그것은 성공이고 실패한 블록은 내가 시작한 후에 결코 호출되지 않습니다.AFNetworking AFHTTPRequestOperation 블록이 호출되지 않습니다.
여기 내 코드 (그것의 이력서)
NSMutableURLRequest *request = [[ServerAPI sharedClient] multipartFormRequestWithMethod:@"POST" path:postUrl parameters:nil constructingBodyWithBlock: ^(id <AFMultipartFormData> formData) {
[formData appendPartWithFileData:picture.picture_data name:@"InputFile" fileName:picture.name mimeType:@"image/jpg"];
}];
AFHTTPRequestOperation *operation = [[ServerAPI sharedClient] HTTPRequestOperationWithRequest: request success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success");
} failure: ^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Failure");
}];
[operation setUploadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
NSLog(@"%f", (totalBytesRead/(float) totalBytesExpectedToRead));
}];
[[ServerAPI sharedClient] enqueueHTTPRequestOperation:operation];
나는 진보의 로그를 볼 수 있지만 성공과 실패 블록이 호출되지 않습니다.
picture.picture_data
는 UIImageJPEGRepresentation(image, 0.7)
ServerAPI로 초기화 NSData
는 AFHTTPClient
의 서브이며 sharedCliend
은 단일 방법이다.
AFNetworking의 이유는 적절한 오류 메시지가 아니라도 내 블록을 호출하지 않기 때문입니다.
감사합니다.
편집 난 그냥이 일하기 전에 동일한 URL에 GET 요청을 수행하며 평소와 같이 작동합니다. 내가 사용하고있는 URL은 다음과 같습니다 : part/_layouts/UploadEx.aspx?List=%7BD432BF97-7175-40C1-8E0D-27D8661CBC90%7D&RootFolder=%2Fpwa%2Fpart%2FLibrary&Source=http%3A%2F%2Fwww%2Emysite%2Ecom%2Fpwa%2Fpart%2FLibrary%2FForms%2FAllItems%2Easpx&IsDlg=1
문제점을 찾을 수 있습니까? – jsetting32