2013-08-13 3 views
1

저는 비디오 업로드 기능이 필요한 응용 프로그램을 만들고 있습니다. 나는 이것에 대한 NSURLRequest를 사용하고 있으며 길이가 1 분 미만인 비디오에 대해서는 정상적으로 작동하지만 비디오가 클 때 문제가 발생합니다. 아무도 그것에 대해 어떤 생각을 가지고 있습니까 ???1 분 이상 비디오를 업로드 할 수 없습니다.

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; 
[request setURL:[NSURL URLWithString:urlString]]; 
[request setCachePolicy:NSURLRequestUseProtocolCachePolicy]; 
[request setHTTPMethod:@"POST"]; 

NSString *boundary = @"----F00"; 
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary]; 
[request addValue:contentType forHTTPHeaderField:@"Content-Type"]; 

fileData = [NSData dataWithContentsOfURL:[mediaDict objectForKey:UIImagePickerControllerMediaURL]]; 
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; 
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"data[file_name]\"; filename=\"%@\"\r\n", filename] dataUsingEncoding:NSUTF8StringEncoding]]; 
[body appendData:[[NSString stringWithFormat: @"Content-Type: %@\r\n\r\n",fileContentType] dataUsingEncoding:NSUTF8StringEncoding]]; 
[body appendData:fileData]; 

[request setHTTPBody:body]; 

NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self]; 

if (theConnection) { 

    // Create the NSMutableData to hold the received data. 

    // receivedData is an instance variable declared elsewhere. 

    self.receivedData = [NSMutableData data]; 

} else { 
    // Inform the user that the connection failed. 
    UIAlertView *didFailWithErrorMessage = [[UIAlertView alloc] initWithTitle: @"NSURLConnection " message: @"didFailWithError" delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil]; 
    [didFailWithErrorMessage show]; 
    [spinnerView removeFromSuperview]; 
} 

정말 고맙습니다.

+1

을 확인? –

+0

안녕하세요. UIImagePicker를 사용하여 비디오를 캡처하고 비디오 길이가 1 분 이상이면 비디오가 서버에 업로드되지 않습니다. 위의 스 니펫은 1 분 미만의 동영상에 대해서는 정상적으로 작동합니다. 내 하찮은 영어 실력에 죄송하다는 말씀을 드리고 싶습니다. 당신이 내가 설명하고 싶은 것을 이해하기를 바랍니다. –

+0

비디오를 어디로 업로드하고 있습니까? 수신 측의 제한 사항은 무엇입니까? –

답변

0

는 제한 시간 간격을 설정하고 "비디오가 큰 경우 원인 문제"당신은 더 이상 특정 정보가 있나요 ... 그것의 작동 여부

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; 
[request setURL:[NSURL URLWithString:urlString]]; 
[request setCachePolicy:NSURLRequestUseProtocolCachePolicy]; 
[request setHTTPMethod:@"POST"]; 
[request setTimeoutInterval:6000]; 
+0

안녕하세요 냅스터 나는 그것을 3600으로했지만 행운이 없었습니다 –

+0

비디오의 크기는 얼마입니까? – Nirmalsinh

+0

어떤 것이 더 크고 1 분 .... 메가 바이트의 크기를 모른다. MB 데이터에 대한 제한 사항이 있습니까? –

관련 문제