と私は、サーバーにファイルを送信するために、コードの下に使用します。デバイスが接続されている場合_kCFStreamErrorCodeKey = -2102が唯一のいくつかのISPの無線LAN
NSString *urlString = [NSString stringWithFormat:@"%@%@",[LIUtility sharedUtility].uploadConnectionURL,BR_SERVER_UPLOAD_ADDRESS_FILE];
self.request =[[NSMutableURLRequest alloc] init];
[self.request setURL:[NSURL URLWithString:urlString]];
[self.request setHTTPMethod:@"POST"];
PKMultipartInputStream *body = [[PKMultipartInputStream alloc] init];
NSString *requestString =[self getRequestStringForRange:range andExtension:fileName];
NSData *requestData = [requestString dataUsingEncoding:NSUTF8StringEncoding];
NSString *jsonLengthString = [NSString stringWithFormat:@"%04lu",(unsigned long)requestData.length];
NSData *jsonLengthData = [jsonLengthString dataUsingEncoding:NSUTF8StringEncoding];
[body addPartWithName:@"jsonLength" data:jsonLengthData];
[body addPartWithName:@"json" data:requestData];
[body addPartWithName:@"separator" string:@"\r\n"];
[body addPartWithName:@"fileData" filename:fileName stream:dataStream streamLength:streamSize];
[self.request setHTTPBodyStream:body];
[self.request setTimeoutInterval:60];
NSString *contentType = LI_CONNECTION_CONTENTTYPE;
[self.request addValue:contentType forHTTPHeaderField: @"Content-Type"];
self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self];
_responseData = [NSMutableData data];
[self.connection start];
ファイルは3G/4G.Theコードでアップロードされても動作しますいくつかのADSLのISPの無線LANが、いくつかの他のISPにコードが動作しないと、私はエラーの下に出る:
Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLStringKey= http://example.net , _kCFStreamErrorCodeKey=-2102, NSErrorFailingURLKey=http:/example.net:80/au, NSLocalizedDescription=The request timed out., _kCFStreamErrorDomainKey=4, NSUnderlyingError=0x16a40410 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2102, NSErrorFailingURLStringKey= http://example.net , NSErrorFailingURLKey= http://example.net , NSLocalizedDescription=The request timed out., _kCFStreamErrorDomainKey=4}}}
誰が問題であるかについてどんな考えを持っていますか?
これは私にとっても役に立ちました。これが関連しているかどうかはわかりませんが、参照のために:Swift、iOS 9.2.1のiPadを使用しているXcode 7.2。新しいApple AirPortに問題がありました。古いものはそうしなかった。 –