AFNetworking의 샘플을 사용하여 여러 부분 양식 업로드 작업을하고 있습니다.NSURLErrorDomain Code = -999 AFNetworking 샘플 코드 사용
[email protected] [03:26:21] [~]
-> % curl --form "[email protected]" http://example.dev/api/v1/sendFile
["Successful"]
위는 내가 함께 작업 AFNetworking 요청을 얻기 위해 노력하고있어 같은 엔드 포인트입니다 :
내가 작업하는 URL에 다중 양식을 가진 PHP 응용 프로그램을 가지고있다. 파일이 API 끝에서 성공적으로 처리 된 경우에만 메시지가 생성됩니다.
2015-01-26 15:16:09.683 digitaltest[8507:241970] Error: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo=0x7fb223551a50 {NSErrorFailingURLKey=http://example.dev/api/v1/sendFile, NSLocalizedDescription=cancelled, NSErrorFailingURLStringKey=http://example.dev/api/v1/sendFile}
다음과
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.dev/upload" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileURL:[NSURL fileURLWithPath:@"file://path/to/image.jpg"] name:@"upload" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil];
} error:nil];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
NSProgress *progress = nil;
NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
NSLog(@"%@ %@", response, responseObject);
}
}];
[uploadTask resume];
이 오류 : 아래
-rw-r--r-- 1 vagrant vagrant 290190 Jan 26 15:26 Snow.jpg
가 AFNetworking 페이지에서 예제 코드입니다 : 아래
는 LS의 출력이 서버에 -lash입니다
iOS 응용 프로그램이 서버에 결코 도달하지 않는다는 PHP 측면의 사용자 정의 로깅에서 확인할 수 있습니다. 이 사이트는 로컬 컴퓨터와 iPad 시뮬레이터 모두에서 볼 수 있으며 리디렉션이 없으며 SSL을 통해 실행되지 않습니다.
나는 기존의 앱과 완전히 새로운 앱으로 샘플 코드를 시험해 보았습니다. 간단한 Hello World 버튼과 함께 행운이 없었습니다.
어떻게 작동합니까? 여기
EDIT: As requested here is additional debug:
2015-01-26 20:38:58.211 digitaltest[9340:276782] fileDataURL: file:/Users/digital/Desktop/snow.jpg -- file:///
2015-01-26 20:38:58.223 digitaltest[9340:276782] error: Error Domain=NSCocoaErrorDomain Code=260 "The operation couldn’t be completed. (Cocoa error 260.)" UserInfo=0x7ff531757020 {NSFilePath=/file:/Users/digital/Desktop/snow.jpg, NSUnderlyingError=0x7ff53177bc90 "The operation couldn’t be completed. No such file or directory"}
파일을 증명 출력이된다
[email protected] [08:39:59] [~]
-> % cd ~/Desktop
[email protected] [08:40:05] [~/Desktop]
-> % LL
zsh: command not found: LL
[email protected] [08:40:06] [~/Desktop]
-> % ll
total 1272
0 drwxr-xr-x+ 15 digital staff 510B 26 Jan 20:35 .
0 drwxr-xr-x+ 113 digital staff 3.8K 26 Jan 20:40 ..
24 [email protected] 1 digital staff 8.0K 26 Jan 20:35 .DS_Store
0 -rw-r--r-- 1 digital staff 0B 15 Jul 2013 .localized
8 [email protected] 1 digital staff 2.5K 5 Jan 15:29 Snow[0].jpg
8 [email protected] 1 digital staff 2.5K 5 Jan 15:29 Snow[1].jpg
8 [email protected] 1 digital staff 2.5K 5 Jan 15:29 Snow[2].jpg
8 [email protected] 1 digital staff 2.5K 5 Jan 15:29 Snow[3].jpg
8 [email protected] 1 digital staff 2.5K 26 Jan 20:35 snow.jpg
참고 타임 스탬프.
찰스 프록시의 요청을 살펴보면 결코 전송되지 않을 수도 있습니다. – zaph
코드에서 파일 URL이 올바른지 확인했습니다 (예 : 파일의 존재 여부 확인)? – zaph
@Zaph url은 정확합니다. Charles Proxy를 살펴보고 그 내용을 확인하십시오. – digital